summaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-03-16 00:59:53 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-03-16 00:59:53 +0000
commit56493c5bdfa181d172acbd56cb69589c28623b47 (patch)
tree11073a4558e6190ed8204eb6d6bdb6028bd40ae3 /game
parentAdd requires on factory like functions (diff)
downloadilt-56493c5bdfa181d172acbd56cb69589c28623b47.tar.bz2
ilt-56493c5bdfa181d172acbd56cb69589c28623b47.tar.xz
ilt-56493c5bdfa181d172acbd56cb69589c28623b47.zip
Allow activities to be changed when doing them
Diffstat (limited to 'game')
-rw-r--r--game/activity.h4
-rw-r--r--game/activityOf.h4
-rw-r--r--game/vehicles/train.cpp4
-rw-r--r--game/vehicles/train.h4
4 files changed, 8 insertions, 8 deletions
diff --git a/game/activity.h b/game/activity.h
index f7eda21..f6ec609 100644
--- a/game/activity.h
+++ b/game/activity.h
@@ -13,7 +13,7 @@ public:
DEFAULT_MOVE_COPY(Activity);
virtual ~Activity() = default;
- virtual void apply(Vehicle *, TickDuration) const = 0;
+ virtual void apply(Vehicle *, TickDuration) = 0;
template<typename T> class Of;
};
@@ -22,7 +22,7 @@ using ActivityPtr = std::unique_ptr<Activity>;
template<typename T> concept ActivityConcept = std::is_base_of_v<Activity, T>;
template<ActivityConcept AC> class Can {
public:
- virtual void doActivity(const AC *, TickDuration) = 0;
+ virtual void doActivity(AC *, TickDuration) = 0;
};
#endif
diff --git a/game/activityOf.h b/game/activityOf.h
index a26efd1..c245866 100644
--- a/game/activityOf.h
+++ b/game/activityOf.h
@@ -6,10 +6,10 @@
template<typename T> class Activity::Of : public Activity {
void
- apply(Vehicle * v, TickDuration dur) const override
+ apply(Vehicle * v, TickDuration dur) override
{
if (auto tv = dynamic_cast<Can<T> *>(v)) {
- tv->doActivity(static_cast<const T *>(this), dur);
+ tv->doActivity(static_cast<T *>(this), dur);
}
}
};
diff --git a/game/vehicles/train.cpp b/game/vehicles/train.cpp
index f887be4..874db46 100644
--- a/game/vehicles/train.cpp
+++ b/game/vehicles/train.cpp
@@ -33,7 +33,7 @@ Train::tick(TickDuration dur)
}
void
-Train::doActivity(const Go *, TickDuration dur)
+Train::doActivity(Go *, TickDuration dur)
{
const auto maxSpeed = objects.front()->rvClass->maxSpeed;
if (speed != maxSpeed) {
@@ -42,7 +42,7 @@ Train::doActivity(const Go *, TickDuration dur)
}
void
-Train::doActivity(const Idle *, TickDuration dur)
+Train::doActivity(Idle *, TickDuration dur)
{
if (speed != 0.F) {
speed -= std::min(speed, 30.F * dur.count());
diff --git a/game/vehicles/train.h b/game/vehicles/train.h
index fb94102..e3dad73 100644
--- a/game/vehicles/train.h
+++ b/game/vehicles/train.h
@@ -28,8 +28,8 @@ public:
void render(const Shader & shader) const override;
void tick(TickDuration elapsed) override;
- void doActivity(const Go *, TickDuration) override;
- void doActivity(const Idle *, TickDuration) override;
+ void doActivity(Go *, TickDuration) override;
+ void doActivity(Idle *, TickDuration) override;
[[nodiscard]] Location getBogiePosition(float linkDist, float dist) const;
};