All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <>
3  * Copyright (C) 2005-2009 MaNGOS <>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <>.
17  */
19 #ifndef TRANSPORTS_H
20 #define TRANSPORTS_H
22 #include "GameObject.h"
23 #include "TransportMgr.h"
24 #include "VehicleDefines.h"
26 struct CreatureData;
29 {
32  Transport();
33  public:
34  typedef std::set<WorldObject*> PassengerSet;
36  ~Transport();
38  bool Create(ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress);
39  void CleanupsBeforeDelete(bool finalCleanup = true) override;
41  void Update(uint32 diff) override;
42  void DelayedUpdate(uint32 diff);
44  void BuildUpdate(UpdateDataMapType& data_map) override;
46  void AddPassenger(WorldObject* passenger);
47  void RemovePassenger(WorldObject* passenger);
48  PassengerSet const& GetPassengers() const { return _passengers; }
50  Creature* CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const* data);
51  GameObject* CreateGOPassenger(ObjectGuid::LowType guid, GameObjectData const* data);
69  TempSummon* SummonPassenger(uint32 entry, Position const& pos, TempSummonType summonType, SummonPropertiesEntry const* properties = NULL, uint32 duration = 0, Unit* summoner = NULL, uint32 spellId = 0, uint32 vehId = 0);
72  void CalculatePassengerPosition(float& x, float& y, float& z, float* o = NULL) const override
73  {
75  }
78  void CalculatePassengerOffset(float& x, float& y, float& z, float* o = NULL) const override
79  {
81  }
84  void SetPeriod(uint32 period) { SetUInt32Value(GAMEOBJECT_LEVEL, period); }
87  KeyFrameVec const& GetKeyFrames() const { return _transportInfo->keyFrames; }
89  void UpdatePosition(float x, float y, float z, float o);
92  void LoadStaticPassengers();
95  void UnloadStaticPassengers();
97  void EnableMovement(bool enabled);
99  void SetDelayedAddModelToMap() { _delayedAddModel = true; }
101  TransportTemplate const* GetTransportTemplate() const { return _transportInfo; }
103  private:
104  void MoveToNextWaypoint();
105  float CalculateSegmentPos(float perc);
106  bool TeleportTransport(uint32 newMapid, float x, float y, float z, float o);
107  void DelayedTeleportTransport();
108  void UpdatePassengerPositions(PassengerSet& passengers);
109  void DoEventIfAny(KeyFrame const& node, bool departure);
112  bool IsMoving() const { return _isMoving; }
113  void SetMoving(bool val) { _isMoving = val; }
117  KeyFrameVec::const_iterator _currentFrame;
118  KeyFrameVec::const_iterator _nextFrame;
120  bool _isMoving;
127  PassengerSet _passengers;
128  PassengerSet::iterator _passengerTeleportItr;
129  PassengerSet _staticPassengers;
133 };
135 #endif
KeyFrameVec::const_iterator _nextFrame
Definition: Transport.h:118
Definition: Creature.h:287
std::vector< KeyFrame > KeyFrameVec
Definition: TransportMgr.h:34
PassengerSet _passengers
Definition: Transport.h:127
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: TemporarySummon.h:40
PassengerSet _staticPassengers
Definition: Transport.h:129
void CalculatePassengerPosition(float &x, float &y, float &z, float *o=NULL) const override
This method transforms supplied transport offsets into global coordinates.
Definition: Transport.h:72
uint32 GetTransportPeriod() const override
Definition: Transport.h:83
arena_t NULL
Definition: jemalloc_internal.h:624
virtual void CalculatePassengerOffset(float &x, float &y, float &z, float *o=NULL) const =0
This method transforms supplied global coordinates into local offsets.
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
bool _pendingStop
Definition: Transport.h:121
struct GameObjectValue::@273 Transport
Definition: Transport.h:28
Definition: Object.h:423
Definition: Creature.h:467
Definition: Timer.h:134
bool _isMoving
Definition: Transport.h:120
Definition: Object.h:52
uint64 LowType
Definition: ObjectGuid.h:199
Definition: VehicleDefines.h:119
virtual void CalculatePassengerPosition(float &x, float &y, float &z, float *o=NULL) const =0
This method transforms supplied transport offsets into global coordinates.
KeyFrameVec const & GetKeyFrames() const
Definition: Transport.h:87
float GetOrientation() const
Definition: Position.h:107
std::unordered_map< Player *, UpdateData > UpdateDataMapType
Definition: Object.h:91
void BuildUpdate(UpdateDataMapType &) override
Definition: Object.cpp:3078
bool _triggeredDepartureEvent
Definition: Transport.h:125
void Update(uint32 p_time) override
Definition: GameObject.cpp:331
TransportTemplate const * GetTransportTemplate() const
Definition: Transport.h:101
float GetPositionY() const
Definition: Position.h:105
G3D::int16 z
Definition: Vector3int16.h:46
void SetMoving(bool val)
Definition: Transport.h:113
Definition: UpdateFields.h:322
TimeTrackerSmall _positionChangeTimer
Definition: Transport.h:119
float GetPositionZ() const
Definition: Position.h:106
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition: GameObject.cpp:98
Definition: GameObject.h:880
Definition: Map.h:259
bool _delayedTeleport
Definition: Transport.h:132
TransportTemplate const * _transportInfo
Definition: Transport.h:115
Definition: GameObject.h:833
void CalculatePassengerOffset(float &x, float &y, float &z, float *o=NULL) const override
This method transforms supplied global coordinates into local offsets.
Definition: Transport.h:78
void SetDelayedAddModelToMap()
Definition: Transport.h:99
bool _triggeredArrivalEvent
These are needed to properly control events triggering only once for each frame.
Definition: Transport.h:124
#define TC_GAME_API
Definition: Define.h:134
bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit=0)
Definition: GameObject.cpp:173
PassengerSet const & GetPassengers() const
Definition: Transport.h:48
Definition: Position.h:27
PassengerSet::iterator _passengerTeleportItr
Definition: Transport.h:128
uint32 PathProgress
Definition: GameObject.h:779
void SetPeriod(uint32 period)
Definition: Transport.h:84
KeyFrameVec::const_iterator _currentFrame
Definition: Transport.h:117
bool _delayedAddModel
Definition: Transport.h:131
Transport * CreateTransport(uint32 entry, ObjectGuid::LowType guid=UI64LIT(0), Map *map=nullptr, uint32 phaseid=0, uint32 phasegroup=0)
Definition: TransportMgr.cpp:359
GameObjectValue const * GetGOValue() const
Definition: GameObject.h:896
Definition: TransportMgr.h:40
G3D::int16 x
Definition: Vector2int16.h:37
float GetPositionX() const
Definition: Position.h:104
std::set< WorldObject * > PassengerSet
Definition: Transport.h:34
Definition: Unit.h:1305
bool IsMoving() const
Helpers to know if stop frame was reached.
Definition: Transport.h:112
Definition: TransportMgr.h:69
uint32 GetTimer() const
Definition: Transport.h:85
Definition: DBCStructure.h:1242