Entity2D.cpp
Go to the documentation of this file.
1 #include "Entity2D.hpp"
2 
3 namespace comp
4 {
5 
6 //------------- Entity2D_TypeId --------------------------------------------------
8 
9 //------------- Entity2D ---------------------------------------------------------
11  type( Entity2D_TypeId() ),
12  v_entity( iv::VLink() ),
13  position( cm, iv::float2( 0, 0 ) ),
14  cm( cm ),
15  _world( nullptr )
16 {
17 }
18 
20 {
21  this->Unregister();
22 }
23 
25 {
26  if( this->_world )
27  {
28  this->owner()->warning( SRC_INFO, "This Entity2D is already registered to a world." );
29  return;
30  }
31 
32  this->position.Index( this, world );
33 
34  this->_world = world;
35  this->_world->Register( this );
36 }
37 
39 {
40  if( !this->_world )
41  return;
42 
43  this->_world->Unregister( this );
44  this->_world = nullptr;
45 
46  this->position.Index();
47 }
48 
50 {
51  return this->_world;
52 }
53 
55 {
56  return this->_world;
57 }
58 
60 {
61  return this->cm;
62 }
63 
64 //------------- Entity2D_Listener -------------------------------------------------
66  iv::GenericListener< Entity2D_Listener >( inst, world ),
67  cm( inst, this, "Entity2D_Listener" )
68 {
70 }
71 
72 //------------- Entity2D_World -------------------------------------------------
74  iv::World< Entity2D >( inst ),
75  iv::GenericListener_Index< Entity2D_Listener >( inst ),
76  iv::ComponentAttr_Index< Entity2D >( inst ),
77  cm( inst, this, "Entity2D_World" )
78 {
80 }
81 
83 {
84  for( Entity2D * component : this->components() )
85  listener->Entity2D_Registered( component );
86 }
87 
89 {
91 }
92 
94 {
96 }
97 
99 {
101 }
102 
103 }