-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathEntity.cpp
executable file
·114 lines (86 loc) · 2.23 KB
/
Entity.cpp
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "Entity.h"
#include <sstream>
#include "Component.h"
#include "World.h"
//#include "EntityManager.h"
using namespace std;
namespace artemis {
Entity::Entity(World * world, int id) {
this->world = world;
this->entityManager = world->getEntityManager();
this->id = id;
}
Entity::~Entity() {
world = NULL;
entityManager = NULL;
}
void Entity::addSystemBit(bitset<BITSIZE> bit) {
systemBits |= bit;
}
void Entity::addTypeBit(bitset<BITSIZE> bit) {
typeBits |= bit;
}
Component* Entity::getComponent(ComponentType & type) {
return entityManager->getComponent(*this, type);
}
ImmutableBag<Component*> & Entity::getComponents() {
return entityManager->getComponents(*this);
}
int Entity::getId() {
return id;
}
bitset<BITSIZE> Entity::getSystemBits() {
return systemBits;
}
bitset<BITSIZE> Entity::getTypeBits() {
return typeBits;
}
long int Entity::getUniqueId() {
return uniqueId;
}
bool Entity::isActive() {
return entityManager->isActive(this->getId());
}
void Entity::refresh() {
world->refreshEntity(*this);
}
void Entity::addComponent(Component * c){
entityManager->addComponent(*this,c);
}
void Entity::removeComponent(ComponentType & type) {
entityManager->removeComponent(*this, type);
}
void Entity::removeSystemBit(bitset<BITSIZE> bit) {
systemBits &= ~bit;
}
void Entity::removeTypeBit(bitset<BITSIZE> bit) {
typeBits &= ~bit;
}
void Entity::reset() {
typeBits = 0;
systemBits = 0;
}
void Entity::setGroup(string group) {
world->getGroupManager()->set(group, *this);
}
void Entity::setSystemBits(bitset<BITSIZE> systemBits) {
this->systemBits = systemBits;
}
void Entity::setTag(string tag) {
world->getTagManager()->subscribe(tag, *this);
}
void Entity::setTypeBits(bitset<BITSIZE> typeBits) {
this->typeBits = typeBits;
}
void Entity::setUniqueId(long int uniqueId) {
this->uniqueId = uniqueId;
}
std::string Entity::toString() {
std::ostringstream oss;
oss << "Entity[" << id << "]\n";
return oss.str();
}
void Entity::remove() {
world->deleteEntity(*this);
}
};