X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgame%2Fstage.cpp;h=7cad5bc250873b9e8c265ce3aacb617a9c8abcdb;hb=e55354bb994276f83592397899bdf77926e8c769;hp=81893e1e1ef8c27ca72db42e456c78462a999452;hpb=fce6e7846814e54de9d38000d2f5e2295ee2119e;p=libs%2Fgame.git diff --git a/source/game/stage.cpp b/source/game/stage.cpp index 81893e1..7cad5bc 100644 --- a/source/game/stage.cpp +++ b/source/game/stage.cpp @@ -1,4 +1,7 @@ #include "stage.h" +#include +#include +#include "accessguard.h" #include "camera.h" #include "root.h" #include "system.h" @@ -7,7 +10,8 @@ using namespace std; namespace Msp::Game { -Stage::Stage(DataFile::Collection &r): +Stage::Stage(Reflection::Reflector &f, DataFile::Collection &r): + reflector(f), resources(r), event_source(event_bus), event_observer(event_bus), @@ -53,8 +57,24 @@ void Stage::synthesize_initial_events(Handle entity, EventObserver &targ void Stage::tick(Time::TimeDelta dt) { - for(const auto &s: systems) - s->tick(dt); + { +#ifdef DEBUG + AccessGuard::BlockForScope _block; +#endif + for(const auto &s: systems) + { + System::Activator act(*s); + try + { + s->tick(dt); + } + catch(const invalid_access &exc) + { + throw invalid_access(format("%s by %s", exc.what(), Debug::demangle(typeid(*s).name()))); + } + } + } + for(const auto &s: systems) s->deferred_tick(); }