diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-03-08 20:03:40 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-03-08 20:03:40 +0000 |
commit | a32a8447028798ef05af33230fbcfa3195ab430c (patch) | |
tree | b311ea9623ac1816f48bdc1cd1f9a8f1d78091a4 /game/activity.h | |
parent | Shut up cppcheck, an STL implementation of that would be stupid (diff) | |
download | ilt-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/activity.h')
-rw-r--r-- | game/activity.h | 38 |
1 files changed, 38 insertions, 0 deletions
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 <game/worldobject.h> +#include <memory> +#include <special_members.hpp> + +class Vehicle; + +class Activity { +public: + Activity() = default; + DEFAULT_MOVE_COPY(Activity); + virtual ~Activity() = default; + + virtual void apply(Vehicle *, TickDuration) const = 0; + + template<typename T> class Of; +}; +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; +}; + +template<typename T> class Activity::Of : public Activity { + void + apply(Vehicle * v, TickDuration dur) const override + { + if (auto tv = dynamic_cast<Can<T> *>(v)) { + tv->doActivity(static_cast<const T *>(this), dur); + } + } +}; + +#endif |