-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtimer.cpp
31 lines (25 loc) · 887 Bytes
/
timer.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
#include "timer/timer.h"
#include <vector>
#include <timer/lua_timer.h>
int TimerManager::addTimer(int32_t timerId, Timer *timer) {
return addElement(timerId,timer);
}
void TimerManager::run(meow_time_t currentTime,engine * gameEngine) {
ConstElementMap * allAllocatedElements = elementMap();
Manager<Timer>::ElementConstIterator iter = allAllocatedElements->begin();
vector<int32_t> timersToDelete;
while (iter != allAllocatedElements->end()) {
if (iter->second->check(currentTime,gameEngine) ) {
if (iter->second->isSingleShot()) {
timersToDelete.push_back(iter->first);
}
}
iter++;
}
vector<int32_t>::iterator timerToDelete = timersToDelete.begin();
while (timerToDelete != timersToDelete.end()) {
deleteElement(*timerToDelete);
timerToDelete++;
}
return;
}