X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgame%2Fbasicsystem.h;h=aa5d9426ea1053d2e4532a91b6b407d5c166c10b;hb=86057ab12bea9aaf40be2f1f2a0a3e64e94f0313;hp=12c272585d47cabaa125ec47928254ff0f00b1ff;hpb=f93a0f0afe8aff4d0bbc8ee393918881cfdd9db8;p=libs%2Fgame.git diff --git a/source/game/basicsystem.h b/source/game/basicsystem.h index 12c2725..aa5d942 100644 --- a/source/game/basicsystem.h +++ b/source/game/basicsystem.h @@ -1,52 +1,28 @@ #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) { } - 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) { - if constexpr(HasTick) - stage.iterate_objects([dt](T &obj){ obj.tick(dt); }); -} - -template -void BasicSystem::post_tick() -{ - if constexpr(HasPostTick) - stage.iterate_objects([](T &obj){ obj.post_tick(); }); + stage.iterate_objects([dt](T &obj){ obj.tick(dt); }); } } // namespace Msp::Game