-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathEntitySystem.cpp
executable file
·52 lines (41 loc) · 1002 Bytes
/
EntitySystem.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
#include "EntitySystem.h"
#include "World.h"
#include "Entity.h"
using namespace std;
namespace artemis {
EntitySystem::~EntitySystem() {
world = NULL;
}
int EntitySystem::getEntityCount(){
return actives.getCount();
}
void EntitySystem::change(Entity& e) {
bool contains = (systemBit & e.getSystemBits()) == systemBit;
bool interest = (typeFlags & e.getTypeBits()) == typeFlags;
if(interest && !contains && typeFlags.any()) {
actives.add(&e);
e.addSystemBit(systemBit);
added(e);
} else if(!interest && contains && typeFlags.any()) {
this->remove(e);
}
}
void EntitySystem::process() {
if(checkProcessing()) {
begin();
processEntities(actives);
end();
}
};
void EntitySystem::setWorld(World *world) {
this->world = world;
};
void EntitySystem::remove(Entity &e) {
actives.remove(&e);
e.removeSystemBit(systemBit);
removed(e);
};
void EntitySystem::setSystemBit(bitset<BITSIZE> bit) {
systemBit = bit;
}
};