]> git.tdb.fi Git - libs/game.git/blobdiff - source/game/basicsystem.h
Adjust component ticking
[libs/game.git] / source / game / basicsystem.h
index 12c272585d47cabaa125ec47928254ff0f00b1ff..aa5d9426ea1053d2e4532a91b6b407d5c166c10b 100644 (file)
@@ -1,52 +1,28 @@
 #ifndef MSP_GAME_BASICSYSTEM_
 #define MSP_GAME_BASICSYSTEM_
 
-#include <msp/time/timedelta.h>
-#include "pool.h"
 #include "stage.h"
 #include "system.h"
 
 namespace Msp::Game {
 
-template<typename T>
-concept HasPreTick = requires(T x) { x.pre_tick(); };
-
 template<typename T>
 concept HasTick = requires(T x) { x.tick(Time::TimeDelta()); };
 
 template<typename T>
-concept HasPostTick = requires(T x) { x.post_tick(); };
-
-template<typename T>
+       requires std::is_base_of_v<Component, T> && HasTick<T>
 class BasicSystem: public System
 {
 public:
        BasicSystem(Stage &s): System(s) { }
 
-       void pre_tick() override;
        void tick(Time::TimeDelta) override;
-       void post_tick() override;
 };
 
-template<typename T>
-void BasicSystem<T>::pre_tick()
-{
-       if constexpr(HasPreTick<T>)
-               stage.iterate_objects<T>([](T &obj){ obj.pre_tick(); });
-}
-
 template<typename T>
 void BasicSystem<T>::tick(Time::TimeDelta dt)
 {
-       if constexpr(HasTick<T>)
-               stage.iterate_objects<T>([dt](T &obj){ obj.tick(dt); });
-}
-
-template<typename T>
-void BasicSystem<T>::post_tick()
-{
-       if constexpr(HasPostTick<T>)
-               stage.iterate_objects<T>([](T &obj){ obj.post_tick(); });
+       stage.iterate_objects<T>([dt](T &obj){ obj.tick(dt); });
 }
 
 } // namespace Msp::Game