forked from GTA-Network/IV-Network
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCTimer.h
62 lines (44 loc) · 1.2 KB
/
CTimer.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
55
56
57
58
59
60
61
62
#ifndef CTimer_h
#define CTimer_h
#include <Scripting/CScriptClass.h>
class CScriptTimer;
class CTimer
{
private:
stScriptFunction m_callback;
unsigned int m_uiInterval;
int m_iRepeatings;
bool m_bPaused;
bool m_bRunning;
unsigned int m_uiLastPulse;
CScriptTimer *m_pScriptTimer;
public:
CTimer(stScriptFunction function, int interval, int repeatings);
~CTimer();
void Start() { m_bRunning = true; };
void Stop();
void Pause() { m_bPaused = true; }
void Resume() { m_bPaused = false; }
bool IsPaused() { return m_bPaused; }
bool IsRunning() { return m_bRunning; };
void SetScriptTimer(CScriptTimer* pTimer) { m_pScriptTimer = pTimer; }
CScriptTimer* GetScriptTimer() { return m_pScriptTimer; }
bool Pulse();
};
class CScriptTimer
{
private:
CTimer *m_pTimer;
public:
CScriptTimer() { }
~CScriptTimer() { }
CTimer* GetTimer() { return m_pTimer; }
void SetTimer(CTimer* pTimer) { m_pTimer = pTimer; }
void Start() { GetTimer()->Start(); };
void Stop() { GetTimer()->Stop(); }
void Pause() { GetTimer()->Pause(); }
void Resume() { GetTimer()->Resume(); }
bool IsPaused() { return GetTimer()->IsPaused(); }
bool IsRunning() { return GetTimer()->IsRunning(); };
};
#endif