forked from matachi/Artemis-Cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Entity.h
executable file
·89 lines (69 loc) · 2.07 KB
/
Entity.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef ENTITY_H
#define ENTITY_H
#include <bitset>
#include <string>
#include <cstddef>
#include <typeinfo>
#include "BitSize.h"
#include "ImmutableBag.h"
#include "EntityManager.h"
#include "ComponentTypeManager.h"
namespace artemis {
class Component;
class ComponentType;
class World;
//class EntityManager;
/**
* The entity class. Cannot be instantiated outside the framework, you must
* create new entities using World.
*/
class Entity {
private:
int id;
long int uniqueId;
std::bitset<BITSIZE> typeBits;
std::bitset<BITSIZE> systemBits;
World * world;
EntityManager * entityManager;
// No copy constructor
Entity(const Entity&);
// No assign operator
Entity& operator=(const Entity&);
protected:
public:
Entity(World * world, int id);
~Entity();
int getId();
void setUniqueId(long int uniqueId);
long int getUniqueId();
std::bitset<BITSIZE> getTypeBits();
void addTypeBit(std::bitset<BITSIZE> bit);
void removeTypeBit(std::bitset<BITSIZE> bit);
std::bitset<BITSIZE> getSystemBits();
void addSystemBit(std::bitset<BITSIZE> bit);
void removeSystemBit(std::bitset<BITSIZE> bit);
void setSystemBits(std::bitset<BITSIZE> systemBits);
void setTypeBits(std::bitset<BITSIZE> typeBits);
void reset();
std::string toString();
void addComponent(Component * c);
//Might change to non template
template<typename c>
void removeComponent() {
entityManager->removeComponent(*this,ComponentTypeManager::getTypeFor<c>());
}
void removeComponent(ComponentType & type);
Component * getComponent(ComponentType & type);
template<typename c>
Component * getComponent() {
return (c*)entityManager->getComponent(*this,ComponentTypeManager::getTypeFor<c>());
}
ImmutableBag<Component*> & getComponents();
bool isActive();
void refresh();
void remove();
void setGroup(std::string group);
void setTag(std::string tag);
};
};
#endif // $(Guard token)