]> git.tdb.fi Git - libs/game.git/blobdiff - source/game/stage.h
Emit events on entity and component creation and destruction
[libs/game.git] / source / game / stage.h
index 47ca47d9a572b6c5742e5a5279877d5af983584c..80e7a4b72c25e51141d43718c6bed196ffdf712c 100644 (file)
@@ -3,6 +3,9 @@
 
 #include <memory>
 #include <msp/time/timedelta.h>
+#include "eventbus.h"
+#include "events.h"
+#include "eventsource.h"
 #include "handle.h"
 
 namespace Msp::Game {
@@ -12,8 +15,14 @@ class System;
 
 class Stage
 {
+public:
+       using EventSource = Game::EventSource<Events::EntityCreated, Events::EntityDestroyed,
+               Events::ComponentCreated, Events::ComponentDestroyed>;
+
 private:
        PoolPool pools;
+       EventBus event_bus;
+       EventSource event_source;
        /* Use unique_ptr because there's only one root per stage so it's pointless
        to put it in a pool. */
        std::unique_ptr<Root> root;
@@ -24,6 +33,8 @@ public:
        ~Stage();
 
        PoolPool &get_pools() { return pools; }
+       EventBus &get_event_bus() { return event_bus; }
+       EventSource &get_event_source() { return event_source; }
        Handle<Root> get_root() { return Handle<Root>::from_object(root.get()); }
 
        template<typename T, typename F>