TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BattlefieldMgr.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
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 BATTLEFIELD_MGR_H_
19 #define BATTLEFIELD_MGR_H_
20 
21 #include "Battlefield.h"
22 
23 class Player;
24 class ZoneScript;
25 
26 // class to handle player enter / leave / areatrigger / GO use events
28 {
29  public:
30  static BattlefieldMgr* instance();
31 
32  // create battlefield events
33  void InitBattlefield();
34 
35  // called when a player enters an battlefield area
36  void HandlePlayerEnterZone(Player* player, uint32 zoneId);
37  // called when player leaves an battlefield area
38  void HandlePlayerLeaveZone(Player* player, uint32 zoneId);
39 
40  // return assigned battlefield
41  Battlefield* GetBattlefieldToZoneId(uint32 zoneId);
42  Battlefield* GetBattlefieldByBattleId(uint32 battleId);
43  Battlefield* GetBattlefieldByQueueId(uint64 queueId);
44 
45  ZoneScript* GetZoneScript(uint32 zoneId);
46 
47  void AddZone(uint32 zoneId, Battlefield* bf);
48 
49  void Update(uint32 diff);
50 
51  private:
53  ~BattlefieldMgr();
54 
55  typedef std::vector<Battlefield*> BattlefieldSet;
56  typedef std::map<uint32 /*zoneId*/, Battlefield*> BattlefieldMap;
57  // contains all initiated battlefield events
58  // used when initing / cleaning up
59  BattlefieldSet _battlefieldSet;
60  // maps the zone ids to an battlefield event
61  // used in player event handling
62  BattlefieldMap _battlefieldMap;
63  // update interval
64  uint32 _updateTimer;
65 };
66 
67 #define sBattlefieldMgr BattlefieldMgr::instance()
68 
69 #endif // BATTLEFIELD_MGR_H_
std::map< uint32, Battlefield * > BattlefieldMap
Definition: BattlefieldMgr.h:56
BattlefieldMap _battlefieldMap
Definition: BattlefieldMgr.h:62
BattlefieldSet _battlefieldSet
Definition: BattlefieldMgr.h:59
Definition: ZoneScript.h:26
Definition: BattlefieldMgr.h:27
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
Definition: Battlefield.h:196
uint32 _updateTimer
Definition: BattlefieldMgr.h:64
#define TC_GAME_API
Definition: Define.h:134
void Update(uint32 diff)
Definition: WeatherMgr.cpp:150
std::vector< Battlefield * > BattlefieldSet
Definition: BattlefieldMgr.h:55