From a32a8447028798ef05af33230fbcfa3195ab430c Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 8 Mar 2021 20:03:40 +0000 Subject: Initial commit of the orders/activities system Has the main window provide some control over our test train --- game/vehicles/train.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'game/vehicles/train.cpp') 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 @@ -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()); + } +} -- cgit v1.2.3