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#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, Position const& offset) 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 Position GetPositionWithOffset(Position const& offset) const override { return Position::GetPositionWithOffset(offset); }
77
79 Position GetPositionOffsetTo(Position const& endPos) const override { return Position::GetPositionOffsetTo(endPos); }
80
81 int32 GetMapIdForSpawning() const override;
82
83 uint32 GetTransportPeriod() const { return m_gameObjectData->Level; }
84 void SetPeriod(uint32 period) { SetLevel(period); }
85 uint32 GetTimer() const { return _pathProgress; }
86 Optional<uint32> GetNextStopTimestamp() const { return _requestStopTimestamp; }
88
89 void UpdatePosition(float x, float y, float z, float o);
90
92 void LoadStaticPassengers();
93
95 void UnloadStaticPassengers();
96
97 void EnableMovement(bool enabled);
98
99 void SetDelayedAddModelToMap() { _delayedAddModel = true; }
100
101 std::string GetDebugInfo() const override;
102
104 uint32 GetExpectedMapId() const;
105
106 private:
107 bool TeleportTransport(uint32 oldMapId, uint32 newMapId, float x, float y, float z, float o);
108 void TeleportPassengersAndHideTransport(uint32 newMapid);
109 void UpdatePassengerPositions(PassengerSet const& passengers);
110
113 std::unique_ptr<boost::dynamic_bitset<uint8>> _eventsToTrigger;
118
121
123};
124
125#endif
std::unordered_map< Player *, UpdateData > UpdateDataMapType
Definition BaseEntity.h:32
#define TC_GAME_API
Definition Define.h:129
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
TempSummonType
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:25
@ GO_DYNFLAG_LO_STOPPED
TransportMovementState
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
std::string GetDebugInfo() const override
void SetLevel(uint32 level)
Definition GameObject.h:281
void Update(uint32 diff) override
void CleanupsBeforeDelete(bool finalCleanup=true) override
bool Create(uint32 entry, Map *map, Position const &pos, QuaternionData const &rotation, uint32 animProgress, GOState goState, uint32 artKit, bool dynamic, ObjectGuid::LowType spawnid)
Definition Map.h:225
uint64 LowType
Definition ObjectGuid.h:321
bool HasDynamicFlag(uint32 flag) const
Definition Object.h:96
virtual void AddPassenger(WorldObject *passenger, Position const &offset)=0
virtual int32 GetMapIdForSpawning() const =0
virtual TransportBase * RemovePassenger(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:112
void SetPeriod(uint32 period)
Definition Transport.h:84
uint32 GetTransportPeriod() const
Definition Transport.h:83
Position GetPositionWithOffset(Position const &offset) const override
This method transforms supplied transport offsets into global coordinates.
Definition Transport.h:76
Optional< uint32 > _requestStopTimestamp
Definition Transport.h:115
PassengerSet const & GetPassengers() const
Definition Transport.h:48
float GetTransportOrientation() const override
Definition Transport.h:73
Position GetPositionOffsetTo(Position const &endPos) const override
This method transforms supplied global coordinates into local offsets.
Definition Transport.h:79
Optional< uint32 > GetNextStopTimestamp() const
Definition Transport.h:86
uint32 _pathProgress
Definition Transport.h:116
PassengerSet _staticPassengers
Definition Transport.h:120
bool _delayedAddModel
Definition Transport.h:122
size_t _currentPathLeg
Definition Transport.h:114
TimeTracker _positionChangeTimer
Definition Transport.h:117
ObjectGuid GetTransportGUID() const override
Definition Transport.h:71
std::set< WorldObject * > PassengerSet
Definition Transport.h:35
TransportTemplate const * _transportInfo
Definition Transport.h:111
void SetDelayedAddModelToMap()
Definition Transport.h:99
std::unique_ptr< boost::dynamic_bitset< uint8 > > _eventsToTrigger
Definition Transport.h:113
PassengerSet _passengers
Definition Transport.h:119
bool IsStopped() const
Definition Transport.h:87
uint32 GetTimer() const
Definition Transport.h:85
Definition Unit.h:635
void BuildUpdate(UpdateDataMapType &) override
Definition Object.cpp:3070
Position GetPositionWithOffset(Position const &offset) const
Definition Position.cpp:61
Position GetPositionOffsetTo(Position const &endPos) const
Definition Position.cpp:47
constexpr float GetOrientation() const
Definition Position.h:90