]> 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 dbffc9960bedb4fd89c55a232dd6dd91f0fb68c5..80e7a4b72c25e51141d43718c6bed196ffdf712c 100644 (file)
@@ -4,6 +4,8 @@
 #include <memory>
 #include <msp/time/timedelta.h>
 #include "eventbus.h"
+#include "events.h"
+#include "eventsource.h"
 #include "handle.h"
 
 namespace Msp::Game {
@@ -13,9 +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;
@@ -27,6 +34,7 @@ public:
 
        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>