TrinityCore
WaypointManager.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 TRINITY_WAYPOINTMANAGER_H
19#define TRINITY_WAYPOINTMANAGER_H
20
21#include "Define.h"
22#include "Field.h"
23#include "Hash.h"
24#include "ObjectGuid.h"
25#include "Position.h"
26#include "WaypointDefines.h"
27#include <unordered_map>
28
29class Unit;
30
32{
33 public:
34 static WaypointMgr* instance();
35
36 // Attempts to reload a single path from database
37 void ReloadPath(uint32 pathId);
38
39 // Loads all paths from database, should only run on startup
40 void LoadPaths();
41 void LoadPathFromDB(Field* fields);
42 void LoadPathNodesFromDB(Field* fields);
43 void DoPostLoadingChecks();
44
45 void VisualizePath(Unit* owner, WaypointPath const* path, Optional<uint32> displayId);
46 void DevisualizePath(Unit* owner, WaypointPath const* path);
47
48 void MoveNode(WaypointPath const* path, WaypointNode const* node, Position const& pos);
49 void DeleteNode(WaypointPath const* path, WaypointNode const* node);
50 void DeleteNode(uint32 pathId, uint32 nodeId);
51
52 WaypointPath const* GetPath(uint32 pathId) const;
53 WaypointNode const* GetNode(WaypointPath const* path, uint32 nodeId) const;
54 WaypointNode const* GetNode(uint32 pathId, uint32 nodeId) const;
55 WaypointPath const* GetPathByVisualGUID(ObjectGuid guid) const;
56 WaypointNode const* GetNodeByVisualGUID(ObjectGuid guid) const;
57 ObjectGuid const& GetVisualGUIDByNode(uint32 pathId, uint32 nodeId) const;
58
59 private:
61
62 void _LoadPaths();
63 void _LoadPathNodes();
64
65 std::unordered_map<uint32 /*pathId*/, WaypointPath> _pathStore;
66
67 std::unordered_map<std::pair<uint32 /*pathId*/, uint32 /*nodeId*/>, ObjectGuid> _nodeToVisualWaypointGUIDsMap;
68 std::unordered_map<ObjectGuid, std::pair<WaypointPath const*, WaypointNode const*>> _visualWaypointGUIDToNodeMap;
69};
70
71#define sWaypointMgr WaypointMgr::instance()
72
73#endif
#define TC_GAME_API
Definition: Define.h:123
uint32_t uint32
Definition: Define.h:142
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:25
Class used to access individual fields of database query result.
Definition: Field.h:90
Definition: Unit.h:627
std::unordered_map< std::pair< uint32, uint32 >, ObjectGuid > _nodeToVisualWaypointGUIDsMap
std::unordered_map< ObjectGuid, std::pair< WaypointPath const *, WaypointNode const * > > _visualWaypointGUIDToNodeMap
std::unordered_map< uint32, WaypointPath > _pathStore