TrinityCore
Loading...
Searching...
No Matches
Transport.cpp
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#include "Transport.h"
19#include "AreaTrigger.h"
20#include "CellImpl.h"
21#include "DB2Stores.h"
22#include "GameEventSender.h"
23#include "GameObjectAI.h"
24#include "GameTime.h"
25#include "Log.h"
26#include "ObjectMgr.h"
27#include "PhasingHandler.h"
28#include "Player.h"
29#include "ScriptMgr.h"
30#include "Totem.h"
31#include "UpdateData.h"
32#include "Vehicle.h"
33#include "WorldPacket.h"
34#include <boost/dynamic_bitset.hpp>
35#include <sstream>
36
37void TransportBase::UpdatePassengerPosition(Map* map, WorldObject* passenger, Position const& position, bool setHomePosition)
38{
39 // transport teleported but passenger not yet (can happen for players)
40 if (passenger->GetMap() != map)
41 return;
42
43 float x, y, z, o;
44 position.GetPosition(x, y, z, o);
45
46 // Do not use Unit::UpdatePosition here, we don't want to remove auras
47 // as if regular movement occurred
48 switch (passenger->GetTypeId())
49 {
50 case TYPEID_UNIT:
51 {
52 Creature* creature = passenger->ToCreature();
53 map->CreatureRelocation(creature, x, y, z, o, false);
54 if (setHomePosition)
56 break;
57 }
58 case TYPEID_PLAYER:
59 //relocate only passengers in world and skip any player that might be still logging in/teleporting
60 if (passenger->IsInWorld() && !passenger->ToPlayer()->IsBeingTeleported())
61 {
62 map->PlayerRelocation(passenger->ToPlayer(), x, y, z, o);
63 passenger->ToPlayer()->SetFallInformation(0, passenger->GetPositionZ());
64 }
65 break;
67 map->GameObjectRelocation(passenger->ToGameObject(), x, y, z, o, false);
68 passenger->ToGameObject()->RelocateStationaryPosition(position);
69 break;
71 map->DynamicObjectRelocation(passenger->ToDynObject(), x, y, z, o);
72 break;
74 map->AreaTriggerRelocation(passenger->ToAreaTrigger(), x, y, z, o);
75 passenger->ToAreaTrigger()->RelocateStationaryPosition(position);
76 break;
77 default:
78 break;
79 }
80
81 if (Unit* unit = passenger->ToUnit())
82 if (Vehicle* vehicle = unit->GetVehicleKit())
83 vehicle->RelocatePassengers();
84}
85
87 _transportInfo(nullptr), _movementState(TransportMovementState::Moving), _eventsToTrigger(std::make_unique<boost::dynamic_bitset<uint8>>()),
88 _currentPathLeg(0), _pathProgress(0), _delayedAddModel(false)
89{
94}
95
101
102bool Transport::Create(ObjectGuid::LowType guidlow, uint32 entry, float x, float y, float z, float ang)
103{
104 Relocate(x, y, z, ang);
105
106 if (!IsPositionValid())
107 {
108 TC_LOG_ERROR("entities.transport", "Transport (GUID: {}) not created. Suggested coordinates isn't valid (X: {} Y: {})",
109 guidlow, x, y);
110 return false;
111 }
112
113 _Create(ObjectGuid::Create<HighGuid::Transport>(guidlow));
114
115 GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry);
116 if (!goinfo)
117 {
118 TC_LOG_ERROR("sql.sql", "Transport not created: entry in `gameobject_template` not found, entry: {}", entry);
119 return false;
120 }
121
122 m_goInfo = goinfo;
123 m_goTemplateAddon = sObjectMgr->GetGameObjectTemplateAddon(entry);
124
125 TransportTemplate const* tInfo = sTransportMgr->GetTransportTemplate(entry);
126 if (!tInfo)
127 {
128 TC_LOG_ERROR("sql.sql", "Transport {} (name: {}) will not be created, missing `transport_template` entry.", entry, goinfo->name);
129 return false;
130 }
131
132 _transportInfo = tInfo;
133 _eventsToTrigger->resize(tInfo->Events.size(), true);
134
135 if (GameObjectOverride const* goOverride = GetGameObjectOverride())
136 {
137 SetFaction(goOverride->Faction);
138 ReplaceAllFlags(GameObjectFlags(goOverride->Flags));
139 }
140
141 _pathProgress = !goinfo->moTransport.allowstopping ? getMSTime() /*might be called before world update loop begins, don't use GameTime*/ % tInfo->TotalPathTime : 0;
142 SetObjectScale(goinfo->size);
143 SetPeriod(tInfo->TotalPathTime);
144 SetEntry(goinfo->entry);
145 SetDisplayId(goinfo->displayId);
149 SetName(goinfo->name);
150 SetLocalRotation(0.0f, 0.0f, 0.0f, 1.0f);
152
153 size_t legIndex;
154 if (Optional<Position> position = _transportInfo->ComputePosition(_pathProgress, nullptr, &legIndex))
155 {
156 Relocate(position->GetPositionX(), position->GetPositionY(), position->GetPositionZ(), position->GetOrientation());
157 _currentPathLeg = legIndex;
158 }
159
160 CreateModel();
161 return true;
162}
163
164void Transport::CleanupsBeforeDelete(bool finalCleanup /*= true*/)
165{
167 while (!_passengers.empty())
168 {
169 WorldObject* obj = *_passengers.begin();
170 RemovePassenger(obj);
171 }
172
174}
175
177{
178 constexpr Milliseconds positionUpdateDelay = 200ms;
179
180 if (AI())
181 AI()->UpdateAI(diff);
182 else if (!AIM_Initialize())
183 TC_LOG_ERROR("entities.transport", "Could not initialize GameObjectAI for Transport");
184
185 sScriptMgr->OnTransportUpdate(this, diff);
186
188
190 if (!GetGOInfo()->moTransport.allowstopping)
193 _pathProgress += diff;
194 else
196
197 if (_pathProgress / GetTransportPeriod() != cycleId)
198 {
199 // reset cycle
200 _eventsToTrigger->set();
201 }
202
204
205 size_t eventToTriggerIndex = _eventsToTrigger->find_first();
206 if (eventToTriggerIndex != boost::dynamic_bitset<uint8>::npos)
207 {
208 while (eventToTriggerIndex < _transportInfo->Events.size() && _transportInfo->Events[eventToTriggerIndex].Timestamp <= timer)
209 {
210 if (TransportPathLeg const* leg = _transportInfo->GetLegForTime(_transportInfo->Events[eventToTriggerIndex].Timestamp))
211 if (leg->MapId == GetMapId())
212 GameEvents::Trigger(_transportInfo->Events[eventToTriggerIndex].EventId, this, this);
213
214 _eventsToTrigger->set(eventToTriggerIndex, false);
215 ++eventToTriggerIndex;
216 }
217 }
218
219 TransportMovementState moveState;
220 size_t legIndex;
221 if (Optional<Position> newPosition = _transportInfo->ComputePosition(timer, &moveState, &legIndex))
222 {
224 _movementState = moveState;
225
226 if (justStopped)
227 {
229 {
232 }
233 }
234
235 if (legIndex != _currentPathLeg)
236 {
238 _currentPathLeg = legIndex;
239 TeleportTransport(oldMapId, _transportInfo->PathLegs[legIndex].MapId, newPosition->GetPositionX(), newPosition->GetPositionY(), newPosition->GetPositionZ(), newPosition->GetOrientation());
240 return;
241 }
242
243 // set position
245 {
246 _positionChangeTimer.Reset(positionUpdateDelay);
248 UpdatePosition(newPosition->GetPositionX(), newPosition->GetPositionY(), newPosition->GetPositionZ(), newPosition->GetOrientation());
249 else
250 {
251 /* There are four possible scenarios that trigger loading/unloading passengers:
252 1. transport moves from inactive to active grid
253 2. the grid that transport is currently in becomes active
254 3. transport moves from active to inactive grid
255 4. the grid that transport is currently in unloads
256 */
257 bool gridActive = GetMap()->IsGridLoaded(GetPositionX(), GetPositionY());
258
259 if (_staticPassengers.empty() && gridActive) // 2.
261 else if (!_staticPassengers.empty() && !gridActive)
262 // 4. - if transports stopped on grid edge, some passengers can remain in active grids
263 // unload all static passengers otherwise passengers won't load correctly when the grid that transport is currently in becomes active
265 }
266 }
267 }
268
269 // Add model to map after we are fully done with moving maps
271 {
272 _delayedAddModel = false;
273 if (m_model)
275 }
276}
277
278void Transport::AddPassenger(WorldObject* passenger, Position const& offset)
279{
280 if (!IsInWorld())
281 return;
282
283 if (_passengers.insert(passenger).second)
284 {
285 passenger->SetTransport(this);
286 passenger->m_movementInfo.transport.guid = GetGUID();
287 passenger->m_movementInfo.transport.pos = offset;
288 TC_LOG_DEBUG("entities.transport", "Object {} boarded transport {}.", passenger->GetName(), GetName());
289
290 if (Player* plr = passenger->ToPlayer())
291 sScriptMgr->OnAddPassenger(this, plr);
292 }
293}
294
296{
297 if (_passengers.erase(passenger) || _staticPassengers.erase(passenger)) // static passenger can remove itself in case of grid unload
298 {
299 passenger->SetTransport(nullptr);
300 passenger->m_movementInfo.transport.Reset();
301 TC_LOG_DEBUG("entities.transport", "Object {} removed from transport {}.", passenger->GetName(), GetName());
302
303 if (Player* plr = passenger->ToPlayer())
304 {
305 sScriptMgr->OnRemovePassenger(this, plr);
306 plr->SetFallInformation(0, plr->GetPositionZ());
307 }
308 }
309
310 return this;
311}
312
314{
315 Map* map = GetMap();
316 if (map->GetCreatureRespawnTime(guid))
317 return nullptr;
318
319 Creature* creature = Creature::CreateCreatureFromDB(guid, map, false, true);
320 if (!creature)
321 return nullptr;
322
323 ASSERT(data);
324
325 creature->SetTransport(this);
326 creature->m_movementInfo.transport.guid = GetGUID();
328 creature->m_movementInfo.transport.seat = -1;
330 creature->SetHomePosition(creature->GetPosition());
332
336
337 if (!creature->IsPositionValid())
338 {
339 TC_LOG_ERROR("entities.transport", "Passenger {} not created. Suggested coordinates aren't valid (X: {} Y: {})", creature->GetGUID().ToString(), creature->GetPositionX(), creature->GetPositionY());
340 delete creature;
341 return nullptr;
342 }
343
346
347 if (!map->AddToMap(creature))
348 {
349 delete creature;
350 return nullptr;
351 }
352
353 _staticPassengers.insert(creature);
354 sScriptMgr->OnAddCreaturePassenger(this, creature);
355 return creature;
356}
357
359{
360 Map* map = GetMap();
361 if (map->GetGORespawnTime(guid))
362 return nullptr;
363
364 GameObject* go = GameObject::CreateGameObjectFromDB(guid, map, false);
365 if (!go)
366 return nullptr;
367
368 ASSERT(data);
369
370 go->SetTransport(this);
376
377 if (!go->IsPositionValid())
378 {
379 TC_LOG_ERROR("entities.transport", "Passenger {} not created. Suggested coordinates aren't valid (X: {} Y: {})", go->GetGUID().ToString(), go->GetPositionX(), go->GetPositionY());
380 delete go;
381 return nullptr;
382 }
383
386
387 if (!map->AddToMap(go))
388 {
389 delete go;
390 return nullptr;
391 }
392
393 _staticPassengers.insert(go);
394 return go;
395}
396
397TempSummon* Transport::SummonPassenger(uint32 entry, Position const& pos, TempSummonType summonType, SummonPropertiesEntry const* properties /*= nullptr*/, Milliseconds duration /*= 0ms*/, Unit* summoner /*= nullptr*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/)
398{
399 Map* map = FindMap();
400 if (!map)
401 return nullptr;
402
404 if (properties)
405 {
406 switch (properties->Control)
407 {
409 mask = UNIT_MASK_GUARDIAN;
410 break;
412 mask = UNIT_MASK_PUPPET;
413 break;
416 mask = UNIT_MASK_MINION;
417 break;
420 {
421 switch (SummonTitle(properties->Title))
422 {
426 mask = UNIT_MASK_GUARDIAN;
427 break;
430 mask = UNIT_MASK_TOTEM;
431 break;
434 mask = UNIT_MASK_SUMMON;
435 break;
437 mask = UNIT_MASK_MINION;
438 break;
439 default:
440 if (properties->GetFlags().HasFlag(SummonPropertiesFlags::JoinSummonerSpawnGroup)) // Mirror Image, Summon Gargoyle
441 mask = UNIT_MASK_GUARDIAN;
442 break;
443 }
444 break;
445 }
446 default:
447 return nullptr;
448 }
449 }
450
451 TempSummon* summon = nullptr;
452 switch (mask)
453 {
454 case UNIT_MASK_SUMMON:
455 summon = new TempSummon(properties, summoner, false);
456 break;
458 summon = new Guardian(properties, summoner, false);
459 break;
460 case UNIT_MASK_PUPPET:
461 summon = new Puppet(properties, summoner);
462 break;
463 case UNIT_MASK_TOTEM:
464 summon = new Totem(properties, summoner);
465 break;
466 case UNIT_MASK_MINION:
467 summon = new Minion(properties, summoner, false);
468 break;
469 }
470
471 Position globalPosition = GetPositionWithOffset(pos);
472
473 if (!summon->Create(map->GenerateLowGuid<HighGuid::Creature>(), map, entry, globalPosition, nullptr, vehId))
474 {
475 delete summon;
476 return nullptr;
477 }
478
479 WorldObject* phaseShiftOwner = this;
480 if (summoner && !(properties && properties->GetFlags().HasFlag(SummonPropertiesFlags::IgnoreSummonerPhase)))
481 phaseShiftOwner = summoner;
482
483 if (phaseShiftOwner)
484 PhasingHandler::InheritPhaseShift(summon, phaseShiftOwner);
485
486 summon->SetCreatedBySpell(spellId);
487
488 summon->SetTransport(this);
491 summon->Relocate(globalPosition);
492 summon->SetHomePosition(globalPosition);
493 summon->SetTransportHomePosition(pos);
494
498
499 summon->InitStats(summoner, duration);
500
501 if (!map->AddToMap<Creature>(summon))
502 {
503 delete summon;
504 return nullptr;
505 }
506
507 _staticPassengers.insert(summon);
508
509 summon->InitSummon(summoner);
510 summon->SetTempSummonType(summonType);
511
512 return summon;
513}
514
519
520void Transport::UpdatePosition(float x, float y, float z, float o)
521{
522 sScriptMgr->OnRelocate(this, GetMapId(), x, y, z);
523
524 bool newActive = GetMap()->IsGridLoaded(x, y);
525 Cell oldCell(GetPositionX(), GetPositionY());
526
527 Relocate(x, y, z, o);
529 SetLocalRotationAngles(o, 0.0f, 0.0f);
531
533
534 /* There are four possible scenarios that trigger loading/unloading passengers:
535 1. transport moves from inactive to active grid
536 2. the grid that transport is currently in becomes active
537 3. transport moves from active to inactive grid
538 4. the grid that transport is currently in unloads
539 */
540 if (_staticPassengers.empty() && newActive) // 1.
542 else if (!_staticPassengers.empty() && !newActive && oldCell.DiffGrid(Cell(GetPositionX(), GetPositionY()))) // 3.
544 else
546 // 4. is handed by grid unload
547}
548
550{
552 if (!mapId)
553 return;
554
555 GridObjectGuidsMap const* grids = sObjectMgr->GetMapObjectGuids(mapId, GetMap()->GetDifficultyID());
556 if (!grids)
557 return;
558
559 for (auto const& [gridId, guids] : *grids)
560 {
561 // GameObjects on transport
562 for (ObjectGuid::LowType spawnId : guids.gameobjects)
563 CreateGOPassenger(spawnId, sObjectMgr->GetGameObjectData(spawnId));
564
565 // Creatures on transport
566 for (ObjectGuid::LowType spawnId : guids.creatures)
567 CreateNPCPassenger(spawnId, sObjectMgr->GetCreatureData(spawnId));
568 }
569}
570
572{
573 while (!_staticPassengers.empty())
574 {
575 WorldObject* obj = *_staticPassengers.begin();
576 obj->AddObjectToRemoveList(); // also removes from _staticPassengers
577 }
578}
579
581{
582 if (!GetGOInfo()->moTransport.allowstopping)
583 return;
584
585 if (!enabled)
586 {
588 }
589 else
590 {
591 _requestStopTimestamp.reset();
594 }
595}
596
597bool Transport::TeleportTransport(uint32 oldMapId, uint32 newMapId, float x, float y, float z, float o)
598{
599 if (oldMapId != newMapId)
600 {
603 return true;
604 }
605 else
606 {
607 UpdatePosition(x, y, z, o);
608
609 // Teleport players, they need to know it
610 for (PassengerSet::iterator itr = _passengers.begin(); itr != _passengers.end(); ++itr)
611 {
612 if ((*itr)->GetTypeId() == TYPEID_PLAYER)
613 {
614 // will be relocated in UpdatePosition of the vehicle
615 if (Unit* veh = (*itr)->ToUnit()->GetVehicleBase())
616 if (veh->GetTransport() == this)
617 continue;
618
619 (*itr)->ToUnit()->NearTeleportTo(GetPositionWithOffset((*itr)->m_movementInfo.transport.pos));
620 }
621 }
622
623 return false;
624 }
625}
626
628{
629 if (newMapid == GetMapId())
630 {
631 AddToWorld();
632
633 for (MapReference const& ref : GetMap()->GetPlayers())
634 {
635 if (ref.GetSource()->GetTransport() != this && ref.GetSource()->InSamePhase(this))
636 {
637 UpdateData data(GetMap()->GetId());
638 BuildCreateUpdateBlockForPlayer(&data, ref.GetSource());
639 ref.GetSource()->m_visibleTransports.insert(GetGUID());
640 WorldPacket packet;
641 data.BuildPacket(&packet);
642 ref.GetSource()->SendDirectMessage(&packet);
643 }
644 }
645 }
646 else
647 {
648 UpdateData data(GetMap()->GetId());
650
651 WorldPacket packet;
652 data.BuildPacket(&packet);
653 for (MapReference const& ref : GetMap()->GetPlayers())
654 {
655 if (ref.GetSource()->GetTransport() != this && ref.GetSource()->m_visibleTransports.count(GetGUID()))
656 {
657 ref.GetSource()->SendDirectMessage(&packet);
658 ref.GetSource()->m_visibleTransports.erase(GetGUID());
659 }
660 }
661
663 }
664
665 PassengerSet passengersToTeleport = _passengers;
666 for (WorldObject* obj : passengersToTeleport)
667 {
668 float destX, destY, destZ, destO;
669 obj->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
670
671 switch (obj->GetTypeId())
672 {
673 case TYPEID_PLAYER:
674 if (!obj->ToPlayer()->TeleportTo({ .Location = WorldLocation(newMapid, destX, destY, destZ, destO), .TransportGuid = GetTransportGUID() }, TELE_TO_NOT_LEAVE_TRANSPORT))
675 RemovePassenger(obj);
676 break;
679 obj->AddObjectToRemoveList();
680 break;
681 default:
682 RemovePassenger(obj);
683 break;
684 }
685 }
686}
687
689{
690 for (WorldObject* passenger : passengers)
691 UpdatePassengerPosition(GetMap(), passenger, GetPositionWithOffset(passenger->m_movementInfo.transport.pos), true);
692}
693
695{
697
698 for (MapReference const& playerReference : GetMap()->GetPlayers())
699 if (playerReference.GetSource()->InSamePhase(this))
700 BuildFieldsUpdate(playerReference.GetSource(), data_map);
701
702 ClearUpdateMask(true);
703}
704
705std::string Transport::GetDebugInfo() const
706{
707 std::stringstream sstr;
708 sstr << GameObject::GetDebugInfo();
709 return sstr.str();
710}
711
std::unordered_map< Player *, UpdateData > UpdateDataMapType
Definition BaseEntity.h:32
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
#define ASSERT
Definition Errors.h:72
#define TC_LOG_DEBUG(filterType__, message__,...)
Definition Log.h:173
#define TC_LOG_ERROR(filterType__, message__,...)
Definition Log.h:182
TempSummonType
@ TYPEID_AREATRIGGER
Definition ObjectGuid.h:49
@ TYPEID_DYNAMICOBJECT
Definition ObjectGuid.h:47
@ TYPEID_GAMEOBJECT
Definition ObjectGuid.h:46
@ TYPEID_UNIT
Definition ObjectGuid.h:43
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
std::unordered_map< uint32, GridObjectGuids > GridObjectGuidsMap
Definition ObjectMgr.h:477
#define sObjectMgr
Definition ObjectMgr.h:1873
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:25
@ TELE_TO_NOT_LEAVE_TRANSPORT
Definition Player.h:910
#define sScriptMgr
Definition ScriptMgr.h:1449
@ GAMEOBJECT_TYPE_MAP_OBJ_TRANSPORT
SummonTitle
@ GO_DYNFLAG_LO_STOPPED
GameObjectFlags
@ GO_STATE_READY
@ GO_STATE_ACTIVE
@ SUMMON_CATEGORY_POSSESSED_VEHICLE
@ SUMMON_CATEGORY_PET
@ SUMMON_CATEGORY_VEHICLE
@ SUMMON_CATEGORY_ALLY
@ SUMMON_CATEGORY_PUPPET
@ SUMMON_CATEGORY_WILD
uint32 getMSTime()
Definition Timer.h:33
TransportMovementState
#define sTransportMgr
@ UNIT_MASK_PUPPET
Definition Unit.h:376
@ UNIT_MASK_TOTEM
Definition Unit.h:373
@ UNIT_MASK_SUMMON
Definition Unit.h:370
@ UNIT_MASK_GUARDIAN
Definition Unit.h:372
@ UNIT_MASK_MINION
Definition Unit.h:371
@ UNIT_STATE_IGNORE_PATHFINDING
Definition Unit.h:303
void RelocateStationaryPosition(Position const &pos)
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
void BuildUpdateChangesMask()
bool IsInWorld() const
Definition BaseEntity.h:158
void _Create(ObjectGuid const &guid)
Definition BaseEntity.h:218
CreateObjectBits m_updateFlag
Definition BaseEntity.h:352
void ClearUpdateMask(bool remove)
virtual void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const
TypeID GetTypeId() const
Definition BaseEntity.h:166
void BuildOutOfRangeUpdateBlock(UpdateData *data) const
void BuildFieldsUpdate(Player *player, UpdateDataMapType &data_map) const
void SetHomePosition(float x, float y, float z, float o)
Definition Creature.h:394
static Creature * CreateCreatureFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap=true, bool allowDuplicate=false)
void GetTransportHomePosition(float &x, float &y, float &z, float &ori) const
Definition Creature.h:401
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 entry, Position const &pos, CreatureData const *data, uint32 vehId, bool dynamic=false)
void SetTransportHomePosition(float x, float y, float z, float o)
Definition Creature.h:399
virtual void UpdateAI(uint32)
void SetLocalRotationAngles(float z_rot, float y_rot, float x_rot)
void SetGoState(GOState state)
GameObjectTemplate const * GetGOInfo() const
Definition GameObject.h:209
void CreateModel()
GOState GetGoState() const
Definition GameObject.h:290
std::string GetDebugInfo() const override
Position m_stationaryPosition
Definition GameObject.h:503
void ReplaceAllFlags(GameObjectFlags flags)
Definition GameObject.h:285
void RemoveFromWorld() override
void SetGoAnimProgress(uint8 animprogress)
Definition GameObject.h:297
static GameObject * CreateGameObjectFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap=true)
GameObjectAI * AI() const
Definition GameObject.h:390
void SetGoType(GameobjectTypes type)
Definition GameObject.h:289
void SetLocalRotation(float qx, float qy, float qz, float qw)
GameObjectTemplateAddon const * m_goTemplateAddon
Definition GameObject.h:494
bool AIM_Initialize()
void UpdateModelPosition()
void RelocateStationaryPosition(float x, float y, float z, float o)
Definition GameObject.h:416
void SetDisplayId(uint32 displayid)
GameObjectTemplate const * m_goInfo
Definition GameObject.h:493
void CleanupsBeforeDelete(bool finalCleanup=true) override
void AddToWorld() override
GameObjectOverride const * GetGameObjectOverride() const
void SetParentRotation(QuaternionData const &rotation)
std::unique_ptr< GameObjectModel > m_model
Definition GameObject.h:406
void SetFaction(uint32 faction) override
Definition GameObject.h:404
Definition Map.h:227
void DynamicObjectRelocation(DynamicObject *go, float x, float y, float z, float orientation)
Definition Map.cpp:1119
void GameObjectRelocation(GameObject *go, float x, float y, float z, float orientation, bool respawnRelocationOnFail=true)
Definition Map.cpp:1090
void CreatureRelocation(Creature *creature, float x, float y, float z, float ang, bool respawnRelocationOnFail=true)
Definition Map.cpp:1058
bool AddToMap(T *)
Definition Map.cpp:527
ObjectGuid::LowType GenerateLowGuid()
Definition Map.h:564
void AreaTriggerRelocation(AreaTrigger *at, float x, float y, float z, float orientation)
Definition Map.cpp:1149
time_t GetGORespawnTime(ObjectGuid::LowType spawnId) const
Definition Map.h:530
time_t GetCreatureRespawnTime(ObjectGuid::LowType spawnId) const
Definition Map.h:529
void InsertGameObjectModel(GameObjectModel const &model)
Definition Map.h:504
bool IsGridLoaded(uint32 gridId) const
Definition Map.h:277
PlayerList const & GetPlayers() const
Definition Map.h:408
void PlayerRelocation(Player *, float x, float y, float z, float orientation)
Definition Map.cpp:1031
std::string ToString() const
uint64 LowType
Definition ObjectGuid.h:321
void SetDynamicFlag(uint32 flag)
Definition Object.h:97
DynamicObject * ToDynObject()
Definition Object.h:141
Player * ToPlayer()
Definition Object.h:126
AreaTrigger * ToAreaTrigger()
Definition Object.h:146
GameObject * ToGameObject()
Definition Object.h:131
Creature * ToCreature()
Definition Object.h:121
void RemoveDynamicFlag(uint32 flag)
Definition Object.h:98
void SetEntry(uint32 entry)
Definition Object.h:90
virtual void SetObjectScale(float scale)
Definition Object.h:93
Unit * ToUnit()
Definition Object.h:116
static void InheritPhaseShift(WorldObject *target, WorldObject const *source)
static void InitDbVisibleMapId(PhaseShift &phaseShift, int32 visibleMapId)
static void InitDbPhaseShift(PhaseShift &phaseShift, uint8 phaseUseFlags, uint16 phaseId, uint32 phaseGroupId)
void SetFallInformation(uint32 time, float z)
Definition Player.cpp:27437
bool IsBeingTeleported() const
Definition Player.h:2385
virtual void InitStats(WorldObject *summoner, Milliseconds duration)
void SetTempSummonType(TempSummonType type)
virtual void InitSummon(WorldObject *summoner)
Definition Totem.h:31
void UpdatePassengerPosition(Map *map, WorldObject *passenger, Position const &position, bool setHomePosition)
Definition Transport.cpp:37
virtual Position GetPositionWithOffset(Position const &offset) const =0
This method transforms supplied transport offsets into global coordinates.
void UpdatePosition(float x, float y, float z, float o)
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
void LoadStaticPassengers()
Needed when transport moves from inactive to active grid.
Optional< uint32 > _requestStopTimestamp
Definition Transport.h:115
void Update(uint32 diff) override
void BuildUpdate(UpdateDataMapType &data_map) override
void EnableMovement(bool enabled)
bool TeleportTransport(uint32 oldMapId, uint32 newMapId, float x, float y, float z, float o)
bool Create(ObjectGuid::LowType guidlow, uint32 entry, float x, float y, float z, float ang)
void UnloadStaticPassengers()
Needed when transport enters inactive grid.
std::string GetDebugInfo() const override
void AddPassenger(WorldObject *passenger, Position const &offset) override
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
Creature * CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const *data)
void UpdatePassengerPositions(PassengerSet const &passengers)
ObjectGuid GetTransportGUID() const override
Definition Transport.h:71
int32 GetMapIdForSpawning() const override
GameObject * CreateGOPassenger(ObjectGuid::LowType guid, GameObjectData const *data)
std::set< WorldObject * > PassengerSet
Definition Transport.h:35
uint32 GetExpectedMapId() const
Returns id of the map that transport is expected to be on, according to current path progress.
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)
Temporarily summons a creature as passenger on this transport.
TransportTemplate const * _transportInfo
Definition Transport.h:111
std::unique_ptr< boost::dynamic_bitset< uint8 > > _eventsToTrigger
Definition Transport.h:113
PassengerSet _passengers
Definition Transport.h:119
void TeleportPassengersAndHideTransport(uint32 newMapid)
void CleanupsBeforeDelete(bool finalCleanup=true) override
Transport * RemovePassenger(WorldObject *passenger) override
Definition Unit.h:647
Unit * GetVehicleBase() const
Definition Unit.cpp:12206
void SetCreatedBySpell(int32 spellId)
Definition Unit.h:875
void AddUnitState(uint32 f)
Definition Unit.h:754
bool BuildPacket(WorldPacket *packet)
constexpr WorldLocation()
Definition Position.h:194
constexpr uint32 GetMapId() const
Definition Position.h:216
Map * GetMap() const
Definition Object.h:411
Map * FindMap() const
Definition Object.h:412
PhaseShift & GetPhaseShift()
Definition Object.h:310
std::string const & GetName() const
Definition Object.h:342
void AddObjectToRemoveList()
Definition Object.cpp:1179
void SetName(std::string newname)
Definition Object.h:343
MovementInfo m_movementInfo
Definition Object.h:548
void SetTransport(TransportBase *t)
Definition Object.cpp:3103
TC_GAME_API void Trigger(uint32 gameEventId, WorldObject *source, WorldObject *target)
uint32 GetGameTimeMS()
Definition GameTime.cpp:57
STL namespace.
Definition Cell.h:38
bool DiffGrid(Cell const &cell) const
Definition Cell.h:55
struct GameObjectTemplate::@199::@216 moTransport
struct MovementInfo::TransportInfo transport
constexpr void SetOrientation(float orientation)
Definition Position.h:82
constexpr float GetPositionX() const
Definition Position.h:87
constexpr float GetPositionY() const
Definition Position.h:88
constexpr void GetPosition(float &x, float &y) const
Definition Position.h:92
bool IsPositionValid() const
Definition Position.cpp:42
constexpr void Relocate(float x, float y)
Definition Position.h:74
constexpr float GetPositionZ() const
Definition Position.h:89
uint8 phaseUseFlags
Definition SpawnData.h:137
uint32 phaseId
Definition SpawnData.h:138
Position spawnPoint
Definition SpawnData.h:136
int32 terrainSwapMap
Definition SpawnData.h:140
uint32 phaseGroup
Definition SpawnData.h:139
EnumFlag< SummonPropertiesFlags > GetFlags() const
void Update(int32 diff)
Definition Timer.h:121
bool Passed() const
Definition Timer.h:131
void Reset(int32 expiry)
Definition Timer.h:136
uint32 GetNextPauseWaypointTimestamp(uint32 time) const
Optional< Position > ComputePosition(uint32 time, TransportMovementState *moveState, size_t *legIndex) const
std::vector< TransportPathEvent > Events
TransportPathLeg const * GetLegForTime(uint32 time) const
std::vector< TransportPathLeg > PathLegs