1 #ifndef MSP_GAME_ENTITY_H_
2 #define MSP_GAME_ENTITY_H_
11 class hierarchy_error: public std::logic_error
14 hierarchy_error(): std::logic_error("hierarchy error") { }
20 Handle<Entity> parent;
21 std::vector<Handle<Component>> components;
22 std::vector<Handle<Entity>> children;
25 Entity(Handle<Entity>);
28 void add_component(Handle<Component>);
29 void remove_component(Handle<Component>);
31 void add_child(Handle<Entity>);
32 void remove_child(Handle<Entity>);
34 Handle<Entity> get_parent() const { return parent; }
35 Handle<Entity> get_root();
40 inline Handle<Entity> Entity::get_root()
42 Handle<Entity> e = Handle<Entity>::from_object(this);
43 while(Handle<Entity> p = e->get_parent())
48 } // namespace Msp::Game