TrinityCore
Vehicle Class Referencefinal

#include <Vehicle.h>

+ Inheritance diagram for Vehicle:

Public Member Functions

 Vehicle (Unit *unit, VehicleEntry const *vehInfo, uint32 creatureEntry)
 
 ~Vehicle ()
 
 Vehicle (Vehicle const &right)=delete
 
 Vehicle (Vehicle &&right)=delete
 
Vehicleoperator= (Vehicle const &right)=delete
 
Vehicleoperator= (Vehicle &&right)=delete
 
void Install ()
 Initializes power type for vehicle. Nothing more. More...
 
void Uninstall ()
 Removes all passengers and sets status to STATUS_UNINSTALLING. No new passengers can be added to the vehicle after this call. More...
 
void Reset (bool evading=false)
 Reapplies immunities and reinstalls accessories. Only has effect for creatures. More...
 
void InstallAllAccessories (bool evading)
 
void ApplyAllImmunities ()
 Applies specific immunities that cannot be set in DB. More...
 
void InstallAccessory (uint32 entry, int8 seatId, bool minion, uint8 type, uint32 summonTime)
 Installs an accessory. More...
 
UnitGetBase () const
 
VehicleEntry const * GetVehicleInfo () const
 
uint32 GetCreatureEntry () const
 
bool HasEmptySeat (int8 seatId) const
 Checks if vehicle's seat specified by 'seatId' is empty. More...
 
UnitGetPassenger (int8 seatId) const
 Gets a passenger on specified seat. More...
 
SeatMap::const_iterator GetNextEmptySeat (int8 seatId, bool next) const
 Gets the next empty seat based on current seat. More...
 
VehicleSeatAddon const * GetSeatAddonForSeatOfPassenger (Unit const *passenger) const
 Gets the vehicle seat addon data for the seat of a passenger. More...
 
uint8 GetAvailableSeatCount () const
 Gets the available seat count. More...
 
bool AddVehiclePassenger (Unit *unit, int8 seatId=-1)
 
VehicleRemovePassenger (WorldObject *passenger) override
 Removes the passenger from the vehicle. More...
 
void RelocatePassengers ()
 Relocate passengers. Must be called after m_base::Relocate. More...
 
void RemoveAllPassengers ()
 Removes all current and pending passengers from the vehicle. More...
 
bool IsVehicleInUse () const
 Returns information whether the vehicle is currently used by any unit. More...
 
bool IsControllableVehicle () const
 
SeatMap::iterator GetSeatIteratorForPassenger (Unit *passenger)
 Gets seat iterator for specified passenger. More...
 
VehicleSeatEntry const * GetSeatForPassenger (Unit const *passenger) const
 Returns information on the seat of specified passenger, represented by the format in VehicleSeat.dbc. More...
 
void RemovePendingEventsForPassenger (Unit *passenger)
 
Milliseconds GetDespawnDelay ()
 
std::string GetDebugInfo () const
 
Trinity::unique_weak_ptr< VehicleGetWeakPtr () const
 
- Public Member Functions inherited from TransportBase
virtual ObjectGuid GetTransportGUID () const =0
 
virtual void CalculatePassengerPosition (float &x, float &y, float &z, float *o=nullptr) const =0
 This method transforms supplied transport offsets into global coordinates. More...
 
virtual void CalculatePassengerOffset (float &x, float &y, float &z, float *o=nullptr) const =0
 This method transforms supplied global coordinates into local offsets. More...
 
virtual float GetTransportOrientation () const =0
 
virtual void AddPassenger (WorldObject *passenger)=0
 
virtual TransportBaseRemovePassenger (WorldObject *passenger)=0
 
void UpdatePassengerPosition (Map *map, WorldObject *passenger, float x, float y, float z, float o, bool setHomePosition)
 
virtual int32 GetMapIdForSpawning () const =0
 

Public Attributes

SeatMap Seats
 The collection of all seats on the vehicle. Including vacant ones. More...
 

Protected Attributes

uint32 UsableSeatNum
 Number of seats that match VehicleSeatEntry::UsableByPlayer, used for proper display flags. More...
 

Private Types

enum  Status { STATUS_NONE , STATUS_INSTALLED , STATUS_UNINSTALLING }
 
typedef std::list< VehicleJoinEvent * > PendingJoinEventContainer
 

Private Member Functions

void InitMovementInfoForBase ()
 Sets correct MovementFlags2 based on VehicleFlags from DBC. More...
 
ObjectGuid GetTransportGUID () const override
 
float GetTransportOrientation () const override
 
void AddPassenger (WorldObject *) override
 Attempts to add a passenger to the vehicle on 'seatId'. More...
 
void CalculatePassengerPosition (float &x, float &y, float &z, float *o) const override
 This method transforms supplied transport offsets into global coordinates. More...
 
void CalculatePassengerOffset (float &x, float &y, float &z, float *o) const override
 This method transforms supplied global coordinates into local offsets. More...
 
int32 GetMapIdForSpawning () const override
 
void RemovePendingEvent (VehicleJoinEvent *e)
 Removes @VehicleJoinEvent objects from pending join event store. This method only removes it after it's executed or aborted to prevent leaving pointers to deleted events. More...
 
void RemovePendingEventsForSeat (int8 seatId)
 Removes any pending events for given seatId. Executed when a @VehicleJoinEvent::Execute is called. More...
 
bool HasPendingEventForSeat (int8 seatId) const
 

Private Attributes

Unit_me
 The underlying unit with the vehicle kit. Can be player or creature. More...
 
VehicleEntry const * _vehicleInfo
 DBC data for vehicle. More...
 
GuidSet vehiclePlayers
 
uint32 _creatureEntry
 Can be different than the entry of _me in case of players. More...
 
Status _status
 Internal variable for sanity checks. More...
 
PendingJoinEventContainer _pendingJoinEvents
 Collection of delayed join events for prospective passengers. More...
 

Friends

class VehicleJoinEvent
 

Additional Inherited Members

- Static Public Member Functions inherited from TransportBase
static void CalculatePassengerPosition (float &x, float &y, float &z, float *o, float transX, float transY, float transZ, float transO)
 
static void CalculatePassengerOffset (float &x, float &y, float &z, float *o, float transX, float transY, float transZ, float transO)
 
- Protected Member Functions inherited from TransportBase
 TransportBase ()
 
virtual ~TransportBase ()
 

Detailed Description

Definition at line 31 of file Vehicle.h.

Member Typedef Documentation

◆ PendingJoinEventContainer

Definition at line 130 of file Vehicle.h.

Member Enumeration Documentation

◆ Status

enum Vehicle::Status
private
Enumerator
STATUS_NONE 
STATUS_INSTALLED 
STATUS_UNINSTALLING 

Definition at line 84 of file Vehicle.h.

Constructor & Destructor Documentation

◆ Vehicle() [1/3]

Vehicle::Vehicle ( Unit unit,
VehicleEntry const *  vehInfo,
uint32  creatureEntry 
)

Definition at line 37 of file Vehicle.cpp.

+ Here is the call graph for this function:

◆ ~Vehicle()

Vehicle::~Vehicle ( )

@Uninstall must be called before this.

Definition at line 61 of file Vehicle.cpp.

◆ Vehicle() [2/3]

Vehicle::Vehicle ( Vehicle const &  right)
delete

◆ Vehicle() [3/3]

Vehicle::Vehicle ( Vehicle &&  right)
delete

Member Function Documentation

◆ AddPassenger()

bool Vehicle::AddPassenger ( WorldObject )
inlineoverrideprivatevirtual

Attempts to add a passenger to the vehicle on 'seatId'.

Author
Machiavelli
Date
17-2-2013
Parameters
unitThe prospective passenger.
seatIdIdentifier for the seat. Value of -1 indicates the next available seat.
Returns
true if it succeeds, false if it fails.

Implements TransportBase.

Definition at line 97 of file Vehicle.h.

◆ AddVehiclePassenger()

bool Vehicle::AddVehiclePassenger ( Unit unit,
int8  seatId = -1 
)

@Prevent adding passengers when vehicle is uninstalling. (Bad script in OnUninstall/OnRemovePassenger/PassengerBoarded hook.)

Definition at line 421 of file Vehicle.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ApplyAllImmunities()

void Vehicle::ApplyAllImmunities ( )

Applies specific immunities that cannot be set in DB.

Author
Machiavelli
Date
17-2-2013

Definition at line 161 of file Vehicle.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalculatePassengerOffset()

void Vehicle::CalculatePassengerOffset ( float &  x,
float &  y,
float &  z,
float *  o 
) const
inlineoverrideprivatevirtual

This method transforms supplied global coordinates into local offsets.

Implements TransportBase.

Definition at line 108 of file Vehicle.h.

+ Here is the call graph for this function:

◆ CalculatePassengerPosition()

void Vehicle::CalculatePassengerPosition ( float &  x,
float &  y,
float &  z,
float *  o 
) const
inlineoverrideprivatevirtual

This method transforms supplied transport offsets into global coordinates.

Implements TransportBase.

Definition at line 100 of file Vehicle.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAvailableSeatCount()

uint8 Vehicle::GetAvailableSeatCount ( ) const

Gets the available seat count.

Author
Machiavelli
Date
17-2-2013
Returns
The available seat count.

Definition at line 690 of file Vehicle.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetBase()

Unit * Vehicle::GetBase ( ) const
inline

Definition at line 49 of file Vehicle.h.

+ Here is the caller graph for this function:

◆ GetCreatureEntry()

uint32 Vehicle::GetCreatureEntry ( ) const
inline

Definition at line 51 of file Vehicle.h.

+ Here is the caller graph for this function:

◆ GetDebugInfo()

std::string Vehicle::GetDebugInfo ( ) const

Definition at line 970 of file Vehicle.cpp.

+ Here is the caller graph for this function:

◆ GetDespawnDelay()

Milliseconds Vehicle::GetDespawnDelay ( )

Definition at line 962 of file Vehicle.cpp.

+ Here is the caller graph for this function:

◆ GetMapIdForSpawning()

int32 Vehicle::GetMapIdForSpawning ( ) const
inlineoverrideprivatevirtual

Implements TransportBase.

Definition at line 115 of file Vehicle.h.

◆ GetNextEmptySeat()

SeatMap::const_iterator Vehicle::GetNextEmptySeat ( int8  seatId,
bool  next 
) const

Gets the next empty seat based on current seat.

Author
Machiavelli
Date
17-2-2013
Parameters
seatIdIdentifier for the current seat.
nexttrue if iterating forward, false means iterating backwards.
Returns
The next empty seat.

Definition at line 314 of file Vehicle.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetPassenger()

Unit * Vehicle::GetPassenger ( int8  seatId) const

Gets a passenger on specified seat.

Author
Machiavelli
Date
17-2-2013
Parameters
seatIdSeat to look on.
Returns
null if it not found, else pointer to passenger if in world

Definition at line 291 of file Vehicle.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSeatAddonForSeatOfPassenger()

VehicleSeatAddon const * Vehicle::GetSeatAddonForSeatOfPassenger ( Unit const *  passenger) const

Gets the vehicle seat addon data for the seat of a passenger.

Author
Ovahlord
Date
28-1-2020
Parameters
passengerIdentifier for the current seat user
Returns
The seat addon data for the currently used seat of a passenger

Definition at line 355 of file Vehicle.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSeatForPassenger()

VehicleSeatEntry const * Vehicle::GetSeatForPassenger ( Unit const *  passenger) const

Returns information on the seat of specified passenger, represented by the format in VehicleSeat.dbc.

Author
Machiavelli
Date
17-2-2013
Parameters
[in,out]Thepassenger for which we check the seat info.
Returns
null if passenger not found on vehicle, else the DBC record for the seat.

Definition at line 647 of file Vehicle.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSeatIteratorForPassenger()

SeatMap::iterator Vehicle::GetSeatIteratorForPassenger ( Unit passenger)

Gets seat iterator for specified passenger.

Author
Machiavelli
Date
17-2-2013
Parameters
[in,out]passengerPassenger to look up.
Returns
The seat iterator for specified passenger if it's found on the vehicle. Otherwise Seats.end() (invalid iterator).

Definition at line 669 of file Vehicle.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetTransportGUID()

ObjectGuid Vehicle::GetTransportGUID ( ) const
inlineoverrideprivatevirtual

Implements TransportBase.

Definition at line 93 of file Vehicle.h.

◆ GetTransportOrientation()

float Vehicle::GetTransportOrientation ( ) const
inlineoverrideprivatevirtual

Implements TransportBase.

Definition at line 95 of file Vehicle.h.

◆ GetVehicleInfo()

VehicleEntry const * Vehicle::GetVehicleInfo ( ) const
inline

Definition at line 50 of file Vehicle.h.

+ Here is the caller graph for this function:

◆ GetWeakPtr()

Trinity::unique_weak_ptr< Vehicle > Vehicle::GetWeakPtr ( ) const

Definition at line 997 of file Vehicle.cpp.

+ Here is the call graph for this function:

◆ HasEmptySeat()

bool Vehicle::HasEmptySeat ( int8  seatId) const

Checks if vehicle's seat specified by 'seatId' is empty.

Author
Machiavelli
Date
17-2-2013
Parameters
seatIdIdentifier for the seat.
Returns
true if empty seat, false if not.

Definition at line 270 of file Vehicle.cpp.

+ Here is the caller graph for this function:

◆ HasPendingEventForSeat()

bool Vehicle::HasPendingEventForSeat ( int8  seatId) const
private

Definition at line 952 of file Vehicle.cpp.

+ Here is the caller graph for this function:

◆ InitMovementInfoForBase()

void Vehicle::InitMovementInfoForBase ( )
private

Sets correct MovementFlags2 based on VehicleFlags from DBC.

Author
Machiavelli
Date
17-2-2013

Definition at line 618 of file Vehicle.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Install()

void Vehicle::Install ( )

Initializes power type for vehicle. Nothing more.

Author
Machiavelli
Date
17-2-2013

Definition at line 78 of file Vehicle.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstallAccessory()

void Vehicle::InstallAccessory ( uint32  entry,
int8  seatId,
bool  minion,
uint8  type,
uint32  summonTime 
)

Installs an accessory.

Author
Machiavelli
Date
17-2-2013
Parameters
entryThe NPC entry of accessory.
seatIdIdentifier for the seat to add the accessory to.
miniontrue if accessory considered a 'minion'. Implies that the accessory will despawn when the vehicle despawns. Essentially that it has no life without the vehicle. Their fates are bound.
typeSee enum @SummonType.
summonTimeTime after which the minion is despawned in case of a timed despawn @type specified.

@Prevent adding accessories when vehicle is uninstalling. (Bad script in OnUninstall/OnRemovePassenger/PassengerBoarded hook.)

If for some reason adding accessory to vehicle fails it will unsummon in @VehicleJoinEvent::Abort

Definition at line 381 of file Vehicle.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstallAllAccessories()

void Vehicle::InstallAllAccessories ( bool  evading)

Definition at line 85 of file Vehicle.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsControllableVehicle()

bool Vehicle::IsControllableVehicle ( ) const

Definition at line 600 of file Vehicle.cpp.

+ Here is the caller graph for this function:

◆ IsVehicleInUse()

bool Vehicle::IsVehicleInUse ( ) const

Returns information whether the vehicle is currently used by any unit.

Author
Shauren
Date
26-2-2013
Returns
true if any passenger is boarded on vehicle, false otherwise.

Definition at line 591 of file Vehicle.cpp.

+ Here is the caller graph for this function:

◆ operator=() [1/2]

Vehicle & Vehicle::operator= ( Vehicle &&  right)
delete

◆ operator=() [2/2]

Vehicle & Vehicle::operator= ( Vehicle const &  right)
delete

◆ RelocatePassengers()

void Vehicle::RelocatePassengers ( )

Relocate passengers. Must be called after m_base::Relocate.

Author
Machiavelli
Date
17-2-2013

Definition at line 554 of file Vehicle.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveAllPassengers()

void Vehicle::RemoveAllPassengers ( )

Removes all current and pending passengers from the vehicle.

Author
Machiavelli
Date
17-2-2013

Setting to_Abort to true will cause @VehicleJoinEvent::Abort to be executed on next @Unit::UpdateEvents call This will properly "reset" the pending join process for the passenger.

Update vehicle pointer in every pending join event - Abort may be called after vehicle is deleted

Definition at line 226 of file Vehicle.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemovePassenger()

Vehicle * Vehicle::RemovePassenger ( WorldObject passenger)
overridevirtual

Removes the passenger from the vehicle.

Author
Machiavelli
Date
17-2-2013
Parameters
[in,out]unitThe passenger to remove.

Implements TransportBase.

Definition at line 492 of file Vehicle.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemovePendingEvent()

void Vehicle::RemovePendingEvent ( VehicleJoinEvent e)
private

Removes @VehicleJoinEvent objects from pending join event store. This method only removes it after it's executed or aborted to prevent leaving pointers to deleted events.

Author
Shauren
Date
22-2-2013
Parameters
[in]eThe VehicleJoinEvent* to remove from pending event store.

Definition at line 714 of file Vehicle.cpp.

+ Here is the caller graph for this function:

◆ RemovePendingEventsForPassenger()

void Vehicle::RemovePendingEventsForPassenger ( Unit passenger)

Definition at line 762 of file Vehicle.cpp.

+ Here is the caller graph for this function:

◆ RemovePendingEventsForSeat()

void Vehicle::RemovePendingEventsForSeat ( int8  seatId)
private

Removes any pending events for given seatId. Executed when a @VehicleJoinEvent::Execute is called.

Removes any pending events for given passenger. Executed when vehicle control aura is removed while adding passenger is in progress.

Author
Machiavelli
Date
23-2-2013
Parameters
seatIdIdentifier for the seat.
Author
Shauren
Date
13-2-2013
Parameters
passengerUnit that is supposed to enter the vehicle.

Definition at line 737 of file Vehicle.cpp.

+ Here is the caller graph for this function:

◆ Reset()

void Vehicle::Reset ( bool  evading = false)

Reapplies immunities and reinstalls accessories. Only has effect for creatures.

Author
Machiavelli
Date
17-2-2013
Parameters
evadingtrue if called from CreatureAI::EnterEvadeMode

Definition at line 138 of file Vehicle.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Uninstall()

void Vehicle::Uninstall ( )

Removes all passengers and sets status to STATUS_UNINSTALLING. No new passengers can be added to the vehicle after this call.

Author
Machiavelli
Date
17-2-2013

@Prevent recursive uninstall call. (Bad script in OnUninstall/OnRemovePassenger/PassengerBoarded hook.)

Definition at line 109 of file Vehicle.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ VehicleJoinEvent

friend class VehicleJoinEvent
friend

Definition at line 80 of file Vehicle.h.

Member Data Documentation

◆ _creatureEntry

uint32 Vehicle::_creatureEntry
private

Can be different than the entry of _me in case of players.

Definition at line 127 of file Vehicle.h.

◆ _me

Unit* Vehicle::_me
private

The underlying unit with the vehicle kit. Can be player or creature.

Definition at line 123 of file Vehicle.h.

◆ _pendingJoinEvents

PendingJoinEventContainer Vehicle::_pendingJoinEvents
private

Collection of delayed join events for prospective passengers.

Definition at line 131 of file Vehicle.h.

◆ _status

Status Vehicle::_status
private

Internal variable for sanity checks.

Definition at line 128 of file Vehicle.h.

◆ _vehicleInfo

VehicleEntry const* Vehicle::_vehicleInfo
private

DBC data for vehicle.

Definition at line 124 of file Vehicle.h.

◆ Seats

SeatMap Vehicle::Seats

The collection of all seats on the vehicle. Including vacant ones.

Definition at line 67 of file Vehicle.h.

◆ UsableSeatNum

uint32 Vehicle::UsableSeatNum
protected

Number of seats that match VehicleSeatEntry::UsableByPlayer, used for proper display flags.

Definition at line 81 of file Vehicle.h.

◆ vehiclePlayers

GuidSet Vehicle::vehiclePlayers
private

Definition at line 125 of file Vehicle.h.


The documentation for this class was generated from the following files: