-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathTransport.h
More file actions
107 lines (91 loc) · 3.89 KB
/
Transport.h
File metadata and controls
107 lines (91 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* Copyright (C) 2008-2013 Trinity <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Updated by: Toba and Baeumchen (maddin)
*/
#ifndef TRANSPORTS_H
#define TRANSPORTS_H
#include "GameObject.h"
#include "VehicleDefines.h"
#include <map>
#include <set>
#include <string>
class Transport : public GameObject, public TransportBase
{
public:
Transport(uint32 period, uint32 script);
~Transport();
bool Create(uint32 guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress, uint32 dynflags);
bool GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids);
void Update(uint32 p_time);
bool AddPassenger(Player* passenger);
bool RemovePassenger(Player* passenger);
void RemovePassenger(Creature* passenger) { m_NPCPassengerSet.erase(passenger); }
typedef std::set<Player*> PlayerSet;
PlayerSet const& GetPassengers() const { return m_passengers; }
typedef std::set<Creature*> CreatureSet;
CreatureSet m_NPCPassengerSet;
uint32 AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y, float z, float o, uint32 anim=0);
Creature* AddNPCPassengerInInstance(uint32 entry, float x, float y, float z, float o, uint32 anim=0);
void UpdatePosition(MovementInfo* mi);
void UpdatePassengerPositions();
void UpdatePlayerPositions();
/// This method transforms supplied transport offsets into global coordinates
void CalculatePassengerPosition(float& x, float& y, float& z, float& o) const;
/// This method transforms supplied global coordinates into local offsets
void CalculatePassengerOffset(float& x, float& y, float& z, float& o) const;
void BuildStartMovePacket(Map const* targetMap);
void BuildStopMovePacket(Map const* targetMap);
uint32 GetScriptId() const { return ScriptId; }
private:
struct WayPoint
{
WayPoint() : mapid(0), x(0), y(0), z(0), teleport(false), id(0) {}
WayPoint(uint32 _mapid, float _x, float _y, float _z, bool _teleport, uint32 _id = 0,
uint32 _arrivalEventID = 0, uint32 _departureEventID = 0)
: mapid(_mapid), x(_x), y(_y), z(_z), teleport(_teleport), id(_id),
arrivalEventID(_arrivalEventID), departureEventID(_departureEventID)
{
}
uint32 mapid;
float x;
float y;
float z;
bool teleport;
uint32 id;
uint32 arrivalEventID;
uint32 departureEventID;
};
typedef std::map<uint32, WayPoint> WayPointMap;
WayPointMap::const_iterator m_curr;
WayPointMap::const_iterator m_next;
uint32 m_pathTime;
uint32 m_timer;
PlayerSet m_passengers;
uint32 currenttguid;
uint32 m_period;
uint32 ScriptId;
public:
WayPointMap m_WayPoints;
uint32 m_nextNodeTime;
private:
void TeleportTransport(uint32 newMapid, float x, float y, float z);
void UpdateForMap(Map const* map);
void DoEventIfAny(WayPointMap::value_type const& node, bool departure);
WayPointMap::const_iterator GetNextWayPoint();
};
#endif