TrinityCore
BattlefieldMgr.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 BATTLEFIELD_MGR_H_
19#define BATTLEFIELD_MGR_H_
20
21#include "Battlefield.h"
22#include "Hash.h"
23#include <memory>
24#include <unordered_map>
25#include <vector>
26
27class Player;
28class ZoneScript;
29
30// class to handle player enter / leave / areatrigger / GO use events
32{
33 public:
36
39
40 static BattlefieldMgr* instance();
41
42 // create battlefield events
43 void InitBattlefield();
44
45 void CreateBattlefieldsForMap(Map* map);
46
47 void DestroyBattlefieldsForMap(Map const* map);
48
49 // called when a player enters an battlefield area
50 void HandlePlayerEnterZone(Player* player, uint32 zoneId);
51 // called when player leaves an battlefield area
52 void HandlePlayerLeaveZone(Player* player, uint32 zoneId);
53
54 bool IsWorldPvpArea(uint32 zoneId) const;
55
56 // return assigned battlefield
57 Battlefield* GetBattlefieldToZoneId(Map const* map, uint32 zoneId);
58 Battlefield* GetBattlefieldByBattleId(Map const* map, uint32 battleId);
59
60 void AddZone(uint32 zoneId, Battlefield* bf);
61
62 void Update(uint32 diff);
63
64 private:
67
68 typedef std::unordered_map<Map const*, std::vector<std::unique_ptr<Battlefield>>> BattlefieldsMapByMap;
69 typedef std::unordered_map<std::pair<Map const*, uint32 /*zoneid*/>, Battlefield*> BattlefieldMapByZone;
70 // contains all initiated battlefield events
71 // used when initing / cleaning up
73 // maps the zone ids to an battlefield event
74 // used in player event handling
76 // update interval
78};
79
80#define sBattlefieldMgr BattlefieldMgr::instance()
81
82#endif // BATTLEFIELD_MGR_H_
#define TC_GAME_API
Definition: Define.h:123
uint32_t uint32
Definition: Define.h:142
BattlefieldMapByZone _battlefieldsByZone
std::unordered_map< std::pair< Map const *, uint32 >, Battlefield * > BattlefieldMapByZone
BattlefieldMgr(BattlefieldMgr const &)=delete
BattlefieldMgr & operator=(BattlefieldMgr &&)=delete
BattlefieldsMapByMap _battlefieldsByMap
BattlefieldMgr & operator=(BattlefieldMgr const &)=delete
std::unordered_map< Map const *, std::vector< std::unique_ptr< Battlefield > > > BattlefieldsMapByMap
BattlefieldMgr(BattlefieldMgr &&)=delete
Definition: Map.h:189
void Update(VignetteData &vignette, WorldObject const *owner)
Definition: Vignette.cpp:90