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/activity.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 game/activity.h (limited to 'game/activity.h') diff --git a/game/activity.h b/game/activity.h new file mode 100644 index 0000000..33c36fd --- /dev/null +++ b/game/activity.h @@ -0,0 +1,38 @@ +#ifndef ACTIVITY_H +#define ACTIVITY_H + +#include +#include +#include + +class Vehicle; + +class Activity { +public: + Activity() = default; + DEFAULT_MOVE_COPY(Activity); + virtual ~Activity() = default; + + virtual void apply(Vehicle *, TickDuration) const = 0; + + template class Of; +}; +using ActivityPtr = std::unique_ptr; + +template concept ActivityConcept = std::is_base_of_v; +template class Can { +public: + virtual void doActivity(const AC *, TickDuration) = 0; +}; + +template class Activity::Of : public Activity { + void + apply(Vehicle * v, TickDuration dur) const override + { + if (auto tv = dynamic_cast *>(v)) { + tv->doActivity(static_cast(this), dur); + } + } +}; + +#endif -- cgit v1.2.3