]> git.tdb.fi Git - libs/game.git/blobdiff - source/game/stage.h
Add an event bus for delivering events
[libs/game.git] / source / game / stage.h
index 060759696914264ce5c177c0d1674a154b253e52..dbffc9960bedb4fd89c55a232dd6dd91f0fb68c5 100644 (file)
@@ -3,18 +3,22 @@
 
 #include <memory>
 #include <msp/time/timedelta.h>
+#include "eventbus.h"
 #include "handle.h"
-#include "root.h"
 
 namespace Msp::Game {
 
+class Root;
 class System;
 
 class Stage
 {
 private:
        PoolPool pools;
-       Root root;
+       EventBus event_bus;
+       /* 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;
        std::vector<std::unique_ptr<System>> systems;
 
 public:
@@ -22,7 +26,8 @@ public:
        ~Stage();
 
        PoolPool &get_pools() { return pools; }
-       Handle<Root> get_root() { return Handle<Root>::from_object(&root); }
+       EventBus &get_event_bus() { return event_bus; }
+       Handle<Root> get_root() { return Handle<Root>::from_object(root.get()); }
 
        template<typename T, typename F>
        void iterate_objects(const F &);