]> git.tdb.fi Git - libs/game.git/blob - source/game/entity.cpp
95ad686b056266c99be89266a5005c7e6941c7d8
[libs/game.git] / source / game / entity.cpp
1 #include "entity.h"
2 #include "component.h"
3 #include "stage.h"
4
5 using namespace std;
6
7 namespace Msp::Game {
8
9 Entity::Entity(Handle<Entity> p):
10         parent(p)
11 { }
12
13 void Entity::add_component(Handle<Component> comp)
14 {
15         if(comp->get_entity().get()!=this)
16                 throw hierarchy_error();
17
18         components.push_back(comp);
19 }
20
21 void Entity::remove_component(Handle<Component> comp)
22 {
23         erase(components, comp);
24 }
25
26 void Entity::add_child(Handle<Entity> child)
27 {
28         if(child->get_parent().get()!=this)
29                 throw hierarchy_error();
30
31         children.push_back(child);
32 }
33
34 void Entity::remove_child(Handle<Entity> child)
35 {
36         erase(children, child);
37 }
38
39 } // namespace Msp::Game