[11385] Add support for static vehicle spawns

Signed-off-by: zergtmn <zerg@myisp.com>
This commit is contained in:
zergtmn 2011-04-20 23:23:47 +06:00
parent 75e1e7c3a3
commit 2835aa5f20
32 changed files with 115 additions and 331 deletions

View file

@ -23,79 +23,7 @@
#include "Unit.h"
#include "Util.h"
Vehicle::Vehicle() : Creature(CREATURE_SUBTYPE_VEHICLE), m_vehicleId(0)
{
m_updateFlag = (UPDATEFLAG_LIVING | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_VEHICLE);
}
Vehicle::~Vehicle()
VehicleInfo::VehicleInfo(VehicleEntry const* entry) :
m_vehicleEntry(entry)
{
}
void Vehicle::AddToWorld()
{
///- Register the vehicle for guid lookup
if(!IsInWorld())
GetMap()->GetObjectsStore().insert<Vehicle>(GetGUID(), (Vehicle*)this);
Unit::AddToWorld();
}
void Vehicle::RemoveFromWorld()
{
///- Remove the vehicle from the accessor
if(IsInWorld())
GetMap()->GetObjectsStore().erase<Vehicle>(GetGUID(), (Vehicle*)NULL);
///- Don't call the function for Creature, normal mobs + totems go in a different storage
Unit::RemoveFromWorld();
}
void Vehicle::SetDeathState(DeathState s) // overwrite virtual Creature::SetDeathState and Unit::SetDeathState
{
Creature::SetDeathState(s);
}
void Vehicle::Update( uint32 update_diff, uint32 diff)
{
Creature::Update(update_diff, diff);
}
bool Vehicle::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* cinfo, uint32 vehicleId, Team team)
{
SetMap(cPos.GetMap());
SetPhaseMask(cPos.GetPhaseMask(), false);
Object::_Create(guidlow, cinfo->Entry, HIGHGUID_VEHICLE);
if (!InitEntry(cinfo->Entry))
return false;
cPos.SelectFinalPoint(this);
if (!cPos.Relocate(this))
return false;
m_defaultMovementType = IDLE_MOTION_TYPE;
AIM_Initialize();
SetVehicleId(vehicleId);
SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f);
CreatureInfo const *ci = GetCreatureInfo();
setFaction(team == ALLIANCE ? ci->faction_A : ci->faction_H);
SelectLevel(ci);
return true;
}
void Vehicle::Dismiss()
{
SendObjectDeSpawnAnim(GetGUID());
CombatStop();
AddObjectToRemoveList();
}