X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgame%2Fstage.h;h=03a8adebc2531e605e5e7e3a58f8ca1dfb573c36;hb=12c863fc1bc5456a4b3aceacc88904d76bd1d8bb;hp=283dc81c0747776875cfed9d0048aa720b1bfbba;hpb=f377d216dfc44e36da3697557f38dfedcbec45d1;p=libs%2Fgame.git diff --git a/source/game/stage.h b/source/game/stage.h index 283dc81..03a8ade 100644 --- a/source/game/stage.h +++ b/source/game/stage.h @@ -8,7 +8,9 @@ #include "events.h" #include "eventsource.h" #include "handle.h" +#include "mspgame_api.h" #include "reflection.h" +#include "systemscheduler.h" namespace Msp::Game { @@ -16,7 +18,7 @@ class Camera; class Root; class System; -class Stage +class MSPGAME_API Stage { public: using EventSource = Game::EventSource root; std::vector> systems; + SystemScheduler scheduler; Handle active_camera; + bool pending_reschedule = false; public: Stage(Reflection::Reflector &, DataFile::Collection &); @@ -78,8 +82,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