[8483] Implement glyph 43361.
[getmangos.git] / src / game / Transports.h
blob1ae05a753e2d9e812eb87432087dfb63b5e4a583
1 /*
2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
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.
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.
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
19 #ifndef TRANSPORTS_H
20 #define TRANSPORTS_H
22 #include "GameObject.h"
24 #include <map>
25 #include <set>
26 #include <string>
28 class TransportPath
30 public:
31 struct PathNode
33 uint32 mapid;
34 float x,y,z;
35 uint32 actionFlag;
36 uint32 delay;
39 void SetLength(const unsigned int sz)
41 i_nodes.resize( sz );
44 unsigned int Size(void) const { return i_nodes.size(); }
45 bool Empty(void) const { return i_nodes.empty(); }
46 void Resize(unsigned int sz) { i_nodes.resize(sz); }
47 void Clear(void) { i_nodes.clear(); }
48 PathNode* GetNodes(void) { return static_cast<PathNode *>(&i_nodes[0]); }
50 PathNode& operator[](const unsigned int idx) { return i_nodes[idx]; }
51 const PathNode& operator()(const unsigned int idx) const { return i_nodes[idx]; }
53 protected:
54 std::vector<PathNode> i_nodes;
57 class Transport : public GameObject
59 public:
60 explicit Transport();
62 bool Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress, uint32 dynflags);
63 bool GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids);
64 void Update(uint32 p_time);
65 bool AddPassenger(Player* passenger);
66 bool RemovePassenger(Player* passenger);
68 typedef std::set<Player*> PlayerSet;
69 PlayerSet const& GetPassengers() const { return m_passengers; }
71 private:
72 struct WayPoint
74 WayPoint() : mapid(0), x(0), y(0), z(0), teleport(false) {}
75 WayPoint(uint32 _mapid, float _x, float _y, float _z, bool _teleport) :
76 mapid(_mapid), x(_x), y(_y), z(_z), teleport(_teleport) {}
77 uint32 mapid;
78 float x;
79 float y;
80 float z;
81 bool teleport;
84 typedef std::map<uint32, WayPoint> WayPointMap;
86 WayPointMap::const_iterator m_curr;
87 WayPointMap::const_iterator m_next;
88 uint32 m_pathTime;
89 uint32 m_timer;
91 PlayerSet m_passengers;
93 public:
94 WayPointMap m_WayPoints;
95 uint32 m_nextNodeTime;
96 uint32 m_period;
98 private:
99 void TeleportTransport(uint32 newMapid, float x, float y, float z);
100 void UpdateForMap(Map const* map);
101 WayPointMap::const_iterator GetNextWayPoint();
103 #endif