TrinityCore
RestMgr.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 RestMgr_h__
19#define RestMgr_h__
20
21#include "Define.h"
22#include <ctime>
23
24class Player;
25
27{
31};
32
34{
39
41};
42
43// Exhaustion.db2 ids
45{
49};
50
52{
55 REST_FLAG_IN_FACTION_AREA = 0x4 // used with AREA_FLAG_REST_ZONE_*
56};
57
59{
60 friend class Player;
61public:
62 explicit RestMgr(Player* player);
64
65 float GetRestBonus(RestTypes restType) const { return _restBonus[restType]; }
66
67 void SetRestBonus(RestTypes restType, float restBonus);
68 void AddRestBonus(RestTypes restType, float restBonus);
69
70 bool HasRestFlag(RestFlag restFlag) const { return (_restFlagMask & restFlag) != 0; }
71 void SetRestFlag(RestFlag restFlag, uint32 triggerId = 0);
72 void RemoveRestFlag(RestFlag restFlag);
73
74 uint32 GetRestBonusFor(RestTypes restType, uint32 xp);
75 uint32 GetInnTriggerID() const { return _innAreaTriggerId; }
76
77 void Update(time_t now);
78
79 float CalcExtraPerSec(RestTypes restType, float bubble) const;
80
81protected:
82 void LoadRestBonus(RestTypes restType, PlayerRestState state, float restBonus);
83
84private:
86 time_t _restTime;
88 float _restBonus[REST_TYPE_MAX];
90};
91
92#endif // RestMgr_h__
#define TC_GAME_API
Definition: Define.h:123
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
PlayerRestState
Definition: RestMgr.h:45
@ REST_STATE_NORMAL
Definition: RestMgr.h:47
@ REST_STATE_RESTED
Definition: RestMgr.h:46
@ REST_STATE_RAF_LINKED
Definition: RestMgr.h:48
PlayerRestInfoOffsets
Definition: RestMgr.h:34
@ REST_STATE_HONOR
Definition: RestMgr.h:37
@ REST_RESTED_HONOR
Definition: RestMgr.h:38
@ MAX_REST_INFO
Definition: RestMgr.h:40
@ REST_STATE_XP
Definition: RestMgr.h:35
@ REST_RESTED_XP
Definition: RestMgr.h:36
RestFlag
Definition: RestMgr.h:52
@ REST_FLAG_IN_TAVERN
Definition: RestMgr.h:53
@ REST_FLAG_IN_FACTION_AREA
Definition: RestMgr.h:55
@ REST_FLAG_IN_CITY
Definition: RestMgr.h:54
RestTypes
Definition: RestMgr.h:27
@ REST_TYPE_MAX
Definition: RestMgr.h:30
@ REST_TYPE_XP
Definition: RestMgr.h:28
@ REST_TYPE_HONOR
Definition: RestMgr.h:29
friend class RestMgr
Definition: Player.h:1112
uint32 GetInnTriggerID() const
Definition: RestMgr.h:75
time_t _restTime
Definition: RestMgr.h:86
Player * _player
Definition: RestMgr.h:85
bool HasRestFlag(RestFlag restFlag) const
Definition: RestMgr.h:70
~RestMgr()
Definition: RestMgr.h:63
uint32 _restFlagMask
Definition: RestMgr.h:89
float GetRestBonus(RestTypes restType) const
Definition: RestMgr.h:65
uint32 _innAreaTriggerId
Definition: RestMgr.h:87
void Update(VignetteData &vignette, WorldObject const *owner)
Definition: Vignette.cpp:90