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