forked from mangosR2/scriptdev2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsc_timer.h
More file actions
36 lines (27 loc) · 1.11 KB
/
sc_timer.h
File metadata and controls
36 lines (27 loc) · 1.11 KB
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
/* Copyright (C) 2013 by boxa for ScriptDev2_R2 <http://github.com/mangosR2/scriptdev2/>
* This program is free software licensed under GPL version 2
* Please see the included DOCS/LICENSE.TXT for more information */
#ifndef SC_TIMER_H
#define SC_TIMER_H
class TTimer
{
public:
TTimer() : m_period(1000), m_counter(0), m_autoReset(false) {}
void Reset() { m_counter = 0; }
void Reset(uint32 const period);
void Reset(uint32 const periodMin, uint32 const periodMax);
void ResetAuto(uint32 const period);
bool Expired(uint32 const tickDiff);
void Update(uint32 const tickDiff) { m_counter += tickDiff; }
bool IsExpired() const { return m_counter >= m_period; }
bool IsSet() const { return m_period > 0; }
void SetAutoReset(bool const autoReset) { m_autoReset = autoReset; }
bool GetAutoReset() const { return m_autoReset; }
uint32 GetPeriod() const { return m_period; }
uint32 GetCounter() const { return m_counter; }
private:
uint32 m_period;
uint32 m_counter;
bool m_autoReset;
};
#endif