1 | /* |
---|
2 | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
---|
3 | * |
---|
4 | * This program is free software; you can redistribute it and/or modify |
---|
5 | * it under the terms of the GNU General Public License as published by |
---|
6 | * the Free Software Foundation; either version 2 of the License, or |
---|
7 | * (at your option) any later version. |
---|
8 | * |
---|
9 | * This program is distributed in the hope that it will be useful, |
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | * GNU General Public License for more details. |
---|
13 | * |
---|
14 | * You should have received a copy of the GNU General Public License |
---|
15 | * along with this program; if not, write to the Free Software |
---|
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef MANGOS_WAYPOINTMANAGER_H |
---|
20 | #define MANGOS_WAYPOINTMANAGER_H |
---|
21 | |
---|
22 | #include <vector> |
---|
23 | #include <string> |
---|
24 | #include "Utilities/HashMap.h" |
---|
25 | |
---|
26 | struct WaypointBehavior |
---|
27 | { |
---|
28 | uint32 emote; |
---|
29 | uint32 spell; |
---|
30 | std::string text[5]; |
---|
31 | uint32 model1; |
---|
32 | uint32 model2; |
---|
33 | |
---|
34 | bool isEmpty(); |
---|
35 | WaypointBehavior() {} |
---|
36 | WaypointBehavior(const WaypointBehavior &b); |
---|
37 | }; |
---|
38 | |
---|
39 | struct WaypointNode |
---|
40 | { |
---|
41 | float x; |
---|
42 | float y; |
---|
43 | float z; |
---|
44 | float orientation; |
---|
45 | uint32 delay; |
---|
46 | WaypointBehavior * behavior; |
---|
47 | WaypointNode() {} |
---|
48 | WaypointNode(float _x, float _y, float _z, float _o, uint32 _delay, WaypointBehavior * _behavior) |
---|
49 | : x(_x), y(_y), z(_z), orientation(_o), delay(_delay), behavior(_behavior) {} |
---|
50 | }; |
---|
51 | |
---|
52 | typedef std::vector<WaypointNode> WaypointPath; |
---|
53 | |
---|
54 | class WaypointManager |
---|
55 | { |
---|
56 | public: |
---|
57 | WaypointManager() {} |
---|
58 | ~WaypointManager() { Unload(); } |
---|
59 | |
---|
60 | void Load(); |
---|
61 | void Unload(); |
---|
62 | |
---|
63 | void Cleanup(); |
---|
64 | |
---|
65 | WaypointPath *GetPath(uint32 id) |
---|
66 | { |
---|
67 | WaypointPathMap::iterator itr = m_pathMap.find(id); |
---|
68 | return itr != m_pathMap.end() ? &itr->second : NULL; |
---|
69 | } |
---|
70 | |
---|
71 | void AddLastNode(uint32 id, float x, float y, float z, float o, uint32 delay, uint32 wpGuid); |
---|
72 | void AddAfterNode(uint32 id, uint32 point, float x, float y, float z, float o, uint32 delay, uint32 wpGuid); |
---|
73 | uint32 GetLastPoint(uint32 id, uint32 default_notfound); |
---|
74 | void DeleteNode(uint32 id, uint32 point); |
---|
75 | void DeletePath(uint32 id); |
---|
76 | void SetNodePosition(uint32 id, uint32 point, float x, float y, float z); |
---|
77 | void SetNodeText(uint32 id, uint32 point, const char *text_field, const char *text); |
---|
78 | |
---|
79 | private: |
---|
80 | void _addNode(uint32 id, uint32 point, float x, float y, float z, float o, uint32 delay, uint32 wpGuid); |
---|
81 | void _clearPath(WaypointPath &path); |
---|
82 | |
---|
83 | typedef HM_NAMESPACE::hash_map<uint32, WaypointPath> WaypointPathMap; |
---|
84 | WaypointPathMap m_pathMap; |
---|
85 | }; |
---|
86 | |
---|
87 | #define WaypointMgr MaNGOS::Singleton<WaypointManager>::Instance() |
---|
88 | |
---|
89 | #endif |
---|