TrinityCore
Loading...
Searching...
No Matches
MirrorTimer.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef TRINITYCORE_MIRROR_TIMER_H
19#define TRINITYCORE_MIRROR_TIMER_H
20
21#include "Define.h"
22#include "EnumFlag.h"
23#include "Timer.h"
24
33
35{
36 None = 0x00,
37 Paused = 0x01,
38 Changed = 0x02,
39 PausedChanged = 0x04
40};
41
43
45{
46public:
47 bool IsActive() const { return m_maxValue > 0; }
48 bool IsRegenerating() const { return m_scale > 0; }
49
50 int32 GetValue() const { return m_value; }
51 void SetValue(int32 value);
52
53 int32 GetMaxValue() const { return m_maxValue; }
54 void SetMaxValue(int32 maxValue);
55
56 int32 GetScale() const { return m_scale; }
57 void SetScale(int32 scale);
58
59 int32 GetSpellId() const { return m_spellId; }
60
62 void SetPaused(bool state);
63
67
68 void Start(int32 maxValue, int32 spellId);
69 void Start(int32 value, int32 maxValue, int32 spellId);
70
71 void Stop();
72
81
83
84private:
90
91 static constexpr Milliseconds ExpiredTickPeriod = 1s;
93};
94
95#endif // TRINITYCORE_MIRROR_TIMER_H
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
#define DEFINE_ENUM_FLAG(enumType)
Definition EnumFlag.h:26
MirrorTimerType
Definition MirrorTimer.h:26
@ MIRROR_TIMER_FATIGUE
Definition MirrorTimer.h:27
@ MIRROR_TIMER_BREATH
Definition MirrorTimer.h:28
@ MIRROR_TIMER_FEIGN_DEATH
Definition MirrorTimer.h:29
@ MIRROR_TIMER_MAX
Definition MirrorTimer.h:31
MirrorTimerFlags
Definition MirrorTimer.h:35
constexpr void RemoveFlag(EnumFlag flag)
Definition EnumFlag.h:101
constexpr bool HasFlag(T flag) const
Definition EnumFlag.h:106
void Start(int32 maxValue, int32 spellId)
static constexpr Milliseconds ExpiredTickPeriod
Definition MirrorTimer.h:91
int32 m_maxValue
Definition MirrorTimer.h:86
PeriodicTimer m_expiredTick
Definition MirrorTimer.h:92
int32 m_value
Definition MirrorTimer.h:85
void SetPaused(bool state)
void SetScale(int32 scale)
int32 GetMaxValue() const
Definition MirrorTimer.h:53
int32 GetScale() const
Definition MirrorTimer.h:56
bool IsPaused() const
Definition MirrorTimer.h:61
int32 m_scale
Definition MirrorTimer.h:87
int32 GetValue() const
Definition MirrorTimer.h:50
void SetMaxValue(int32 maxValue)
int32 m_spellId
Definition MirrorTimer.h:88
int32 GetSpellId() const
Definition MirrorTimer.h:59
bool IsPausedChanged() const
Definition MirrorTimer.h:65
UpdateResult Update(uint32 diff)
bool IsActive() const
Definition MirrorTimer.h:47
EnumFlag< MirrorTimerFlags > m_flags
Definition MirrorTimer.h:89
void SetValue(int32 value)
bool IsRegenerating() const
Definition MirrorTimer.h:48
bool IsChanged() const
Definition MirrorTimer.h:64
void ClearChanged()
Definition MirrorTimer.h:66