]> git.tdb.fi Git - libs/game.git/blobdiff - source/game/entity.cpp
Add a transform component and propagation system
[libs/game.git] / source / game / entity.cpp
index 95ad686b056266c99be89266a5005c7e6941c7d8..8f56f670cb50de28c68876c64f12a9405c6c3278 100644 (file)
@@ -1,15 +1,27 @@
 #include "entity.h"
 #include "component.h"
-#include "stage.h"
+#include "root.h"
+#include "transform.h"
 
 using namespace std;
 
 namespace Msp::Game {
 
-Entity::Entity(Handle<Entity> p):
+Entity::Entity(Handle<Entity> p, TransformTag):
        parent(p)
 { }
 
+Entity::Entity(Handle<Entity> p, const TransformValues &tv):
+       parent(p),
+       transform(*this)
+{
+       transform->set_values(tv);
+}
+
+// Hide ~Owned<Transform> from the header
+Entity::~Entity()
+{ }
+
 void Entity::add_component(Handle<Component> comp)
 {
        if(comp->get_entity().get()!=this)
@@ -36,4 +48,10 @@ void Entity::remove_child(Handle<Entity> child)
        erase(children, child);
 }
 
+Stage &Entity::get_stage()
+{
+       Handle<Entity> root = get_root();
+       return dynamic_cast<Root &>(*root).get_stage();
+}
+
 } // namespace Msp::Game