X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgame%2Fstage.h;fp=source%2Fgame%2Fstage.h;h=0c2219bdc18b1d893851ed91467677c5a35fc4b1;hb=e4f03880d49bdbe0c7269be0f40f23b197bcea77;hp=283dc81c0747776875cfed9d0048aa720b1bfbba;hpb=423b49f2857f8e1597b652bfd41dbf3ae45f7ec5;p=libs%2Fgame.git diff --git a/source/game/stage.h b/source/game/stage.h index 283dc81..0c2219b 100644 --- a/source/game/stage.h +++ b/source/game/stage.h @@ -9,6 +9,7 @@ #include "eventsource.h" #include "handle.h" #include "reflection.h" +#include "systemscheduler.h" namespace Msp::Game { @@ -33,7 +34,9 @@ private: to put it in a pool. */ std::unique_ptr root; std::vector> systems; + SystemScheduler scheduler; Handle active_camera; + bool pending_reschedule = false; public: Stage(Reflection::Reflector &, DataFile::Collection &); @@ -78,8 +81,13 @@ inline void Stage::iterate_objects(const F &func) template inline T &Stage::add_system(Args &&... args) { - systems.emplace_back(std::make_unique(*this, std::forward(args)...)); - return static_cast(*systems.back()); + // Ensure that a reflected class exists for scheduling + reflector.get_or_create_class(); + + auto &sys = systems.emplace_back(std::make_unique(*this, std::forward(args)...)); + scheduler.add_system(*sys); + pending_reschedule = true; + return static_cast(*sys); } template