]> git.tdb.fi Git - libs/game.git/blobdiff - source/game/director.cpp
Add reflection infrastructure
[libs/game.git] / source / game / director.cpp
index 4a4c1265e82d12ba897f65f1879b8db8f6b7ac33..53b2e7f9a3a0c8668580a139355133eebe7b3f61 100644 (file)
@@ -1,6 +1,8 @@
 #include "director.h"
 #include <stdexcept>
 #include <msp/time/utils.h>
+#include "component.h"
+#include "entity.h"
 #include "stage.h"
 
 using namespace std;
@@ -14,6 +16,9 @@ Director::Director(DataFile::Collection &r):
 #if DEBUG
        access_guard.emplace();
 #endif
+
+       reflector.get_or_create_class<Entity>().set_polymorphic_base<Entity>();
+       reflector.get_or_create_class<Component>().set_polymorphic_base<Component>();
 }
 
 // Hide ~unique_ptr<Stage> from the header
@@ -22,7 +27,7 @@ Director::~Director()
 
 Stage &Director::create_stage()
 {
-       stages.emplace_back(std::make_unique<Stage>(std::ref(resources)));
+       stages.emplace_back(std::make_unique<Stage>(std::ref(reflector), std::ref(resources)));
        event_source.emit<Events::StageCreated>(std::ref(*stages.back()));
        return *stages.back();
 }