TrinityCore
Loading...
Searching...
No Matches
Transport.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef TRANSPORTS_H
19#define TRANSPORTS_H
20
21#include "GameObject.h"
22#include "TransportMgr.h"
23#include "VehicleDefines.h"
24
25struct CreatureData;
26
28{
30
31 Transport();
32 public:
33 typedef std::set<WorldObject*> PassengerSet;
34
35 ~Transport();
36
37 bool Create(ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress);
38 void CleanupsBeforeDelete(bool finalCleanup = true) override;
39
40 void Update(uint32 diff) override;
41 void DelayedUpdate(uint32 diff);
42
43 void BuildUpdate(UpdateDataMapType& data_map) override;
44
45 void AddPassenger(WorldObject* passenger);
46 void RemovePassenger(WorldObject* passenger);
47 PassengerSet const& GetPassengers() const { return _passengers; }
48
49 Creature* CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const* data);
50 GameObject* CreateGOPassenger(ObjectGuid::LowType guid, GameObjectData const* data);
51
68 TempSummon* SummonPassenger(uint32 entry, Position const& pos, TempSummonType summonType, SummonPropertiesEntry const* properties = nullptr, uint32 duration = 0, Unit* summoner = nullptr, uint32 spellId = 0, uint32 vehId = 0);
69
71 void CalculatePassengerPosition(float& x, float& y, float& z, float* o = nullptr) const override
72 {
74 }
75
77 void CalculatePassengerOffset(float& x, float& y, float& z, float* o = nullptr) const override
78 {
80 }
81
83 void SetPeriod(uint32 period) { SetLevel(period); }
85
86 KeyFrameVec const& GetKeyFrames() const { return _transportInfo->keyFrames; }
87
88 void UpdatePosition(float x, float y, float z, float o);
89
91 void LoadStaticPassengers();
92
94 void UnloadStaticPassengers();
95
96 void EnableMovement(bool enabled);
97
98 void SetDelayedAddModelToMap() { _delayedAddModel = true; }
99
100 TransportTemplate const* GetTransportTemplate() const { return _transportInfo; }
101
102 std::string GetDebugInfo() const override;
103
104 private:
105 void MoveToNextWaypoint();
106 float CalculateSegmentPos(float perc);
107 bool TeleportTransport(uint32 newMapid, float x, float y, float z, float o);
108 void DelayedTeleportTransport();
109 void UpdatePassengerPositions(PassengerSet& passengers);
110 void DoEventIfAny(KeyFrame const& node, bool departure);
111
113 bool IsMoving() const { return _isMoving; }
114 void SetMoving(bool val) { _isMoving = val; }
115
117
118 KeyFrameVec::const_iterator _currentFrame;
119 KeyFrameVec::const_iterator _nextFrame;
123
127
129 PassengerSet::iterator _passengerTeleportItr;
131
134};
135
136#endif
#define TC_GAME_API
Definition Define.h:114
uint32_t uint32
Definition Define.h:133
TempSummonType
std::unordered_map< Player *, UpdateData > UpdateDataMapType
Definition Object.h:63
std::vector< KeyFrame > KeyFrameVec
@ GAMEOBJECT_LEVEL
std::string GetDebugInfo() const override
GameObjectValue const * GetGOValue() const
Definition GameObject.h:106
void SetLevel(uint32 level)
Definition GameObject.h:175
void CleanupsBeforeDelete(bool finalCleanup=true) override
void Update(uint32 p_time) override
bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map *map, uint32 phaseMask, Position const &pos, QuaternionData const &rotation, uint32 animprogress, GOState go_state, uint32 artKit=0, bool dynamic=false, ObjectGuid::LowType spawnid=0)
Definition Map.h:281
uint32 LowType
Definition ObjectGuid.h:142
uint32 GetUInt32Value(uint16 index) const
Definition Object.cpp:249
virtual void CalculatePassengerPosition(float &x, float &y, float &z, float *o=nullptr) const =0
This method transforms supplied transport offsets into global coordinates.
virtual void CalculatePassengerOffset(float &x, float &y, float &z, float *o=nullptr) const =0
This method transforms supplied global coordinates into local offsets.
Transport * CreateTransport(uint32 entry, ObjectGuid::LowType guid=0, Map *map=nullptr)
void SetPeriod(uint32 period)
Definition Transport.h:83
bool _triggeredArrivalEvent
These are needed to properly control events triggering only once for each frame.
Definition Transport.h:125
void CalculatePassengerOffset(float &x, float &y, float &z, float *o=nullptr) const override
This method transforms supplied global coordinates into local offsets.
Definition Transport.h:77
uint32 GetTransportPeriod() const override
Definition Transport.h:82
PassengerSet const & GetPassengers() const
Definition Transport.h:47
KeyFrameVec::const_iterator _currentFrame
Definition Transport.h:118
PassengerSet _staticPassengers
Definition Transport.h:130
bool _delayedAddModel
Definition Transport.h:132
KeyFrameVec const & GetKeyFrames() const
Definition Transport.h:86
bool _pendingStop
Definition Transport.h:122
TimeTracker _positionChangeTimer
Definition Transport.h:120
bool _triggeredDepartureEvent
Definition Transport.h:126
TransportTemplate const * GetTransportTemplate() const
Definition Transport.h:100
PassengerSet::iterator _passengerTeleportItr
Definition Transport.h:129
std::set< WorldObject * > PassengerSet
Definition Transport.h:33
bool _isMoving
Definition Transport.h:121
KeyFrameVec::const_iterator _nextFrame
Definition Transport.h:119
TransportTemplate const * _transportInfo
Definition Transport.h:116
bool _delayedTeleport
Definition Transport.h:133
void SetDelayedAddModelToMap()
Definition Transport.h:98
bool IsMoving() const
Helpers to know if stop frame was reached.
Definition Transport.h:113
PassengerSet _passengers
Definition Transport.h:128
void CalculatePassengerPosition(float &x, float &y, float &z, float *o=nullptr) const override
This method transforms supplied transport offsets into global coordinates.
Definition Transport.h:71
uint32 GetTimer() const
Definition Transport.h:84
void SetMoving(bool val)
Definition Transport.h:114
Definition Unit.h:769
void BuildUpdate(UpdateDataMapType &) override
Definition Object.cpp:3559
float GetPositionZ() const
Definition Position.h:81
float GetOrientation() const
Definition Position.h:82
float GetPositionX() const
Definition Position.h:79
float GetPositionY() const
Definition Position.h:80
struct GameObjectValue::@187 Transport
uint32 PathProgress
Definition GameObject.h:48