forked from lfeng1420/BrickGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimerManager.h
55 lines (41 loc) · 962 Bytes
/
TimerManager.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
#pragma once
class ITimerHandler;
class CTimerManager : public Ref
{
public:
CTimerManager();
~CTimerManager();
// Set timer
bool SetTimer(ITimerHandler* pHandler, int nTimerID, int nInterval, int nCallTimes, const char* szDesc);
// Kill timer
void KillTimer(ITimerHandler* pHandler, int nTimerID);
// Update per frame
void update(float dt);
public:
// Create
bool Create();
// Close
void Close();
private:
struct _TTimerData
{
int nTimerID;
int nInterval;
ITimerHandler* pHandler;
std::string strDesc;
int nCurInterval;
int nCallTimes;
};
typedef list<_TTimerData> TList_Timer;
typedef TList_Timer::iterator TList_TimerIter;
private:
// Find timer
_TTimerData* __GetTimerData(int nTimerID, ITimerHandler* pHandler);
// Remove timer
void __RemoveTimerData(int nTimerID, ITimerHandler* pHandler);
// Update all timer
void __UpdateAllTimerData(int nInterval);
private:
// Timer list
TList_Timer m_lsTimer;
};