X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgame%2Fbasicsystem.h;h=37bd20ad2eb62ade7b40ca407a5c59d21b0ab646;hb=a99b57a74252fd3de649d544d070b747f91fcf4d;hp=12c272585d47cabaa125ec47928254ff0f00b1ff;hpb=248d62f7240d342982ade65a510be912b867fe49;p=libs%2Fgame.git diff --git a/source/game/basicsystem.h b/source/game/basicsystem.h index 12c2725..37bd20a 100644 --- a/source/game/basicsystem.h +++ b/source/game/basicsystem.h @@ -1,52 +1,36 @@ #ifndef MSP_GAME_BASICSYSTEM_ #define MSP_GAME_BASICSYSTEM_ -#include -#include "pool.h" #include "stage.h" #include "system.h" namespace Msp::Game { -template -concept HasPreTick = requires(T x) { x.pre_tick(); }; - template concept HasTick = requires(T x) { x.tick(Time::TimeDelta()); }; template -concept HasPostTick = requires(T x) { x.post_tick(); }; - -template + requires std::is_base_of_v && HasTick class BasicSystem: public System { public: - BasicSystem(Stage &s): System(s) { } + BasicSystem(Stage &); - void pre_tick() override; void tick(Time::TimeDelta) override; - void post_tick() override; }; -template -void BasicSystem::pre_tick() -{ - if constexpr(HasPreTick) - stage.iterate_objects([](T &obj){ obj.pre_tick(); }); -} template -void BasicSystem::tick(Time::TimeDelta dt) +BasicSystem::BasicSystem(Stage &s): + System(s) { - if constexpr(HasTick) - stage.iterate_objects([dt](T &obj){ obj.tick(dt); }); + declare_dependency(UPDATE); } template -void BasicSystem::post_tick() +void BasicSystem::tick(Time::TimeDelta dt) { - if constexpr(HasPostTick) - stage.iterate_objects([](T &obj){ obj.post_tick(); }); + stage.iterate_objects([dt](T &obj){ obj.tick(dt); }); } } // namespace Msp::Game