Entity2D.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <ivorium.hpp>
4 #include <unordered_set>
5 
6 namespace comp
7 {
8 
9 class Entity2D_World;
10 
11 //------------- Entity2D_TypeId -------------------------------------------------
15 class Entity2D_TypeId final : public iv::RuntimeId< Entity2D_TypeId >
16 {
17 public:
18  static constexpr char TypeName[] = "Entity2D_TypeId";
21 };
22 
23 //------------- Entity2D -------------------------------------------------
27 class Entity2D
28 {
29 public:
31  ~Entity2D();
32 
33  void Register( Entity2D_World * world );
34  void Unregister();
35 
37  bool registered();
39 
40  // identity - do not change on registered entity
43 
44  // state
46 
47 private:
48  iv::ClientMarker * cm;
49  Entity2D_World * _world;
50 };
51 
52 //------------- Entity2D_Listener -------------------------------------------------
57 class Entity2D_Listener : public iv::GenericListener< Entity2D_Listener >
58 {
59 public:
61 
63 
64  virtual void Entity2D_Registered( Entity2D * ){}
65  virtual void Entity2D_Unregistered( Entity2D * ){}
66  virtual void Entity2D_Moved( Entity2D * ){}
67 
68 private:
69  iv::Instance * inst;
70  Entity2D_World * world;
71 };
72 
73 //------------- Entity2D_World -------------------------------------------------
77 class Entity2D_World : public iv::World< Entity2D >, public iv::GenericListener_Index< Entity2D_Listener >, public iv::ComponentAttr_Index< Entity2D >
78 {
79 public:
82 
83  Entity2D_World( iv::Instance * inst );
84 
85 protected:
86  // iv::GenericListener_Index< Entity2D_Listener >
87  virtual void Listener_Initialize( Entity2D_Listener * ) override;
88 
89  // iv::World< Entity2D >
90  virtual void Component_Registered( Entity2D * entity ) override;
91  virtual void Component_Unregistered( Entity2D * entity ) override;
92 
93  // iv::ComponentAttr_Index< Entity2D >
94  virtual void Component_AttrChanged( Entity2D * entity, iv::Attribute * attr ) override;
95 };
96 
97 }
98 
99 namespace std
100 {
101 template<> struct hash< comp::Entity2D_TypeId > : public iv::hash< comp::Entity2D_TypeId >{};
102 }