forked from matachi/Artemis-Cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DelayedEntitySystem.cpp
executable file
·70 lines (55 loc) · 1.06 KB
/
DelayedEntitySystem.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
#include "DelayedEntitySystem.h"
#include "World.h"
namespace artemis {
DelayedEntitySystem::DelayedEntitySystem() {
acc = 0;
delay = 0;
running = false;
autoRepeat = false;
}
bool DelayedEntitySystem::checkProcessing() {
if(running) {
acc += world->getDelta();
if(acc >= delay) {
return true;
}
}
return false;
}
float DelayedEntitySystem::getInitialTimeDelay() {
return delay;
}
float DelayedEntitySystem::getRemainingTime() {
if(running) {
return delay - acc;
}
return 0;
}
bool DelayedEntitySystem::isRunning() {
return running;
}
void DelayedEntitySystem::setAutoRepeat(bool repeat) {
autoRepeat = repeat;
}
void DelayedEntitySystem::processEntities(ImmutableBag<Entity*>& bag) {
processEntities(bag, acc);
if(autoRepeat) {
start(delay);
} else {
stop();
}
}
void DelayedEntitySystem::start(float delay) {
this->delay = delay;
acc = 0.0f;
running = true;
}
void DelayedEntitySystem::stop() {
acc = 0;
running = false;
}
void DelayedEntitySystem::runNow()
{
acc = delay;
}
};