summaryrefslogtreecommitdiff
path: root/game/vehicles/train.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-03-08 20:03:40 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-03-08 20:03:40 +0000
commita32a8447028798ef05af33230fbcfa3195ab430c (patch)
treeb311ea9623ac1816f48bdc1cd1f9a8f1d78091a4 /game/vehicles/train.cpp
parentShut up cppcheck, an STL implementation of that would be stupid (diff)
downloadilt-a32a8447028798ef05af33230fbcfa3195ab430c.tar.bz2
ilt-a32a8447028798ef05af33230fbcfa3195ab430c.tar.xz
ilt-a32a8447028798ef05af33230fbcfa3195ab430c.zip
Initial commit of the orders/activities system
Has the main window provide some control over our test train
Diffstat (limited to 'game/vehicles/train.cpp')
-rw-r--r--game/vehicles/train.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/game/vehicles/train.cpp b/game/vehicles/train.cpp
index e211f16..f7b5515 100644
--- a/game/vehicles/train.cpp
+++ b/game/vehicles/train.cpp
@@ -1,6 +1,7 @@
#include "train.h"
#include "game/vehicles/linkHistory.h"
#include "game/vehicles/railVehicle.h"
+#include "game/vehicles/railVehicleClass.h"
#include "gfx/renderable.h"
#include "location.hpp"
#include <algorithm>
@@ -53,8 +54,26 @@ Train::getBogiePosition(float linkDist, float dist) const
void
Train::tick(TickDuration dur)
{
+ currentActivity->apply(this, dur);
move(dur);
float trailBy {0.F};
apply(&RailVehicle::move, this, std::ref(trailBy));
}
+
+void
+Train::doActivity(const Go *, TickDuration dur)
+{
+ const auto maxSpeed = objects.front()->rvClass->maxSpeed;
+ if (speed != maxSpeed) {
+ speed += ((maxSpeed - speed) * dur.count());
+ }
+}
+
+void
+Train::doActivity(const Idle *, TickDuration dur)
+{
+ if (speed != 0.F) {
+ speed -= std::min(speed, 30.F * dur.count());
+ }
+}