1 #ifndef MSP_GAME_DIRECTOR_H_
2 #define MSP_GAME_DIRECTOR_H_
7 #include <msp/datafile/collection.h>
8 #include <msp/time/timedelta.h>
9 #include <msp/time/timestamp.h>
10 #include "accessguard.h"
13 #include "eventsource.h"
14 #include "mspgame_api.h"
15 #include "reflection.h"
21 class MSPGAME_API Director
24 using EventSource = Game::EventSource<Events::StageCreated, Events::StageActivated, Events::StageDeactivated>;
27 std::optional<AccessGuard> access_guard;
28 Reflection::Reflector reflector;
29 DataFile::Collection &resources;
31 EventSource event_source;
32 std::vector<std::unique_ptr<Stage>> stages;
33 Stage *active_stage = nullptr;
34 Time::TimeStamp last_tick;
35 Time::TimeDelta stepsize = Time::sec/60;
36 Time::TimeDelta backlog;
37 unsigned max_steps_per_frame = 5;
38 unsigned max_backlog_steps = 600;
41 Director(DataFile::Collection &);
44 DataFile::Collection &get_resources() const { return resources; }
45 EventBus &get_event_bus() { return event_bus; }
46 EventSource &get_event_source() { return event_source; }
47 const std::vector<std::unique_ptr<Stage>> &get_stages() const { return stages; }
49 Stage &create_stage();
50 void activate_stage(Stage &);
51 Stage *get_active_stage() const { return active_stage; }
56 } // namespace Msp::Game