summaryrefslogtreecommitdiff
path: root/game/vehicles/train.cpp
diff options
context:
space:
mode:
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());
+ }
+}