TrinityCore
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#include <boost/dynamic_bitset_fwd.hpp>
25
26struct CreatureData;
28
29class TC_GAME_API Transport final : public GameObject, public TransportBase
30{
32
33 Transport();
34 public:
35 typedef std::set<WorldObject*> PassengerSet;
36
37 ~Transport();
38
39 bool Create(ObjectGuid::LowType guidlow, uint32 entry, float x, float y, float z, float ang);
40 void CleanupsBeforeDelete(bool finalCleanup = true) override;
41
42 void Update(uint32 diff) override;
43
44 void BuildUpdate(UpdateDataMapType& data_map) override;
45
46 void AddPassenger(WorldObject* passenger) override;
47 Transport* RemovePassenger(WorldObject* passenger) override;
48 PassengerSet const& GetPassengers() const { return _passengers; }
49
50 Creature* CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const* data);
51 GameObject* CreateGOPassenger(ObjectGuid::LowType guid, GameObjectData const* data);
52
69 TempSummon* SummonPassenger(uint32 entry, Position const& pos, TempSummonType summonType, SummonPropertiesEntry const* properties = nullptr, Milliseconds duration = 0ms, Unit* summoner = nullptr, uint32 spellId = 0, uint32 vehId = 0);
70
71 ObjectGuid GetTransportGUID() const override { return GetGUID(); }
72
73 float GetTransportOrientation() const override { return GetOrientation(); }
74
76 void CalculatePassengerPosition(float& x, float& y, float& z, float* o = nullptr) const override
77 {
79 }
80
82 void CalculatePassengerOffset(float& x, float& y, float& z, float* o = nullptr) const override
83 {
85 }
86
87 int32 GetMapIdForSpawning() const override;
88
89 uint32 GetTransportPeriod() const { return m_gameObjectData->Level; }
90 void SetPeriod(uint32 period) { SetLevel(period); }
91 uint32 GetTimer() const { return _pathProgress; }
92
93 void UpdatePosition(float x, float y, float z, float o);
94
96 void LoadStaticPassengers();
97
99 void UnloadStaticPassengers();
100
101 void EnableMovement(bool enabled);
102
103 void SetDelayedAddModelToMap() { _delayedAddModel = true; }
104
105 std::string GetDebugInfo() const override;
106
108 uint32 GetExpectedMapId() const;
109
110 private:
111 bool TeleportTransport(uint32 oldMapId, uint32 newMapId, float x, float y, float z, float o);
112 void TeleportPassengersAndHideTransport(uint32 newMapid, float x, float y, float z, float o);
113 void UpdatePassengerPositions(PassengerSet const& passengers);
114
117 std::unique_ptr<boost::dynamic_bitset<uint8>> _eventsToTrigger;
122
125
127};
128
129#endif
#define TC_GAME_API
Definition: Define.h:123
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:29
TempSummonType
Definition: ObjectDefines.h:62
std::unordered_map< Player *, UpdateData > UpdateDataMapType
Definition: Object.h:79
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:25
TransportMovementState
Definition: TransportMgr.h:44
std::string GetDebugInfo() const override
void SetLevel(uint32 level)
Definition: GameObject.h:278
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition: GameObject.cpp:876
bool Create(uint32 entry, Map *map, Position const &pos, QuaternionData const &rotation, uint32 animProgress, GOState goState, uint32 artKit, bool dynamic, ObjectGuid::LowType spawnid)
Definition: GameObject.cpp:956
void Update(uint32 p_time) override
Definition: Map.h:189
uint64 LowType
Definition: ObjectGuid.h:278
ObjectGuid const & GetGUID() const
Definition: Object.h:160
virtual void CalculatePassengerPosition(float &x, float &y, float &z, float *o=nullptr) const =0
This method transforms supplied transport offsets into global coordinates.
virtual float GetTransportOrientation() const =0
virtual int32 GetMapIdForSpawning() const =0
virtual TransportBase * RemovePassenger(WorldObject *passenger)=0
virtual void CalculatePassengerOffset(float &x, float &y, float &z, float *o=nullptr) const =0
This method transforms supplied global coordinates into local offsets.
virtual void AddPassenger(WorldObject *passenger)=0
Transport * CreateTransport(uint32 entry, Map *map, ObjectGuid::LowType guid=0, uint8 phaseUseFlags=0, uint32 phaseId=0, uint32 phaseGroupId=0)
TransportMovementState _movementState
Definition: Transport.h:116
void SetPeriod(uint32 period)
Definition: Transport.h:90
uint32 GetTransportPeriod() const
Definition: Transport.h:89
Optional< uint32 > _requestStopTimestamp
Definition: Transport.h:119
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:82
PassengerSet const & GetPassengers() const
Definition: Transport.h:48
float GetTransportOrientation() const override
Definition: Transport.h:73
uint32 _pathProgress
Definition: Transport.h:120
PassengerSet _staticPassengers
Definition: Transport.h:124
bool _delayedAddModel
Definition: Transport.h:126
size_t _currentPathLeg
Definition: Transport.h:118
TimeTracker _positionChangeTimer
Definition: Transport.h:121
ObjectGuid GetTransportGUID() const override
Definition: Transport.h:71
std::set< WorldObject * > PassengerSet
Definition: Transport.h:35
TransportTemplate const * _transportInfo
Definition: Transport.h:115
void SetDelayedAddModelToMap()
Definition: Transport.h:103
std::unique_ptr< boost::dynamic_bitset< uint8 > > _eventsToTrigger
Definition: Transport.h:117
PassengerSet _passengers
Definition: Transport.h:123
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:76
uint32 GetTimer() const
Definition: Transport.h:91
Definition: Unit.h:627
void BuildUpdate(UpdateDataMapType &) override
Definition: Object.cpp:3728
constexpr float GetPositionX() const
Definition: Position.h:76
constexpr float GetPositionY() const
Definition: Position.h:77
constexpr float GetOrientation() const
Definition: Position.h:79
constexpr float GetPositionZ() const
Definition: Position.h:78