Core/DynamicObject: Research dynamicobject types, added DynamicObjectType enum
This commit is contained in:
@@ -27,7 +27,8 @@
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
DynamicObject::DynamicObject() : WorldObject()
|
||||
DynamicObject::DynamicObject() : WorldObject(),
|
||||
_aura(NULL), _caster(NULL), _duration(0), _isViewpoint(false)
|
||||
{
|
||||
m_objectType |= TYPEMASK_DYNAMICOBJECT;
|
||||
m_objectTypeId = TYPEID_DYNAMICOBJECT;
|
||||
@@ -35,19 +36,14 @@ DynamicObject::DynamicObject() : WorldObject()
|
||||
m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_POSITION);
|
||||
|
||||
m_valuesCount = DYNAMICOBJECT_END;
|
||||
|
||||
m_aura = NULL;
|
||||
m_duration = 0;
|
||||
m_caster = NULL;
|
||||
m_isViewpoint = false;
|
||||
}
|
||||
|
||||
DynamicObject::~DynamicObject()
|
||||
{
|
||||
// make sure all references were properly removed
|
||||
ASSERT(!m_aura);
|
||||
ASSERT(!m_caster);
|
||||
ASSERT(!m_isViewpoint);
|
||||
ASSERT(!_aura);
|
||||
ASSERT(!_caster);
|
||||
ASSERT(!_isViewpoint);
|
||||
}
|
||||
|
||||
void DynamicObject::AddToWorld()
|
||||
@@ -66,10 +62,10 @@ void DynamicObject::RemoveFromWorld()
|
||||
///- Remove the dynamicObject from the accessor and from all lists of objects in world
|
||||
if (IsInWorld())
|
||||
{
|
||||
if (m_isViewpoint)
|
||||
if (_isViewpoint)
|
||||
RemoveCasterViewpoint();
|
||||
|
||||
if (m_aura)
|
||||
if (_aura)
|
||||
RemoveAura();
|
||||
|
||||
// dynobj could get removed in Aura::RemoveAura
|
||||
@@ -82,7 +78,7 @@ void DynamicObject::RemoveFromWorld()
|
||||
}
|
||||
}
|
||||
|
||||
bool DynamicObject::Create(uint32 guidlow, Unit *caster, uint32 spellId, const Position &pos, float radius, bool active)
|
||||
bool DynamicObject::Create(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, bool active, DynamicObjectType type)
|
||||
{
|
||||
SetMap(caster->GetMap());
|
||||
Relocate(pos);
|
||||
@@ -103,7 +99,7 @@ bool DynamicObject::Create(uint32 guidlow, Unit *caster, uint32 spellId, const P
|
||||
// If any other value is used, the client will _always_ use the radius provided in DYNAMICOBJECT_RADIUS, but
|
||||
// precompensation is necessary (eg radius *= 2) for many spells. Anyway, blizz sends 0x0001 for all the spells
|
||||
// I saw sniffed...
|
||||
SetUInt32Value(DYNAMICOBJECT_BYTES, 0x00000001);
|
||||
SetByteValue(DYNAMICOBJECT_BYTES, 0, type);
|
||||
SetUInt32Value(DYNAMICOBJECT_SPELLID, spellId);
|
||||
SetFloatValue(DYNAMICOBJECT_RADIUS, radius);
|
||||
SetUInt32Value(DYNAMICOBJECT_CASTTIME, getMSTime());
|
||||
@@ -115,24 +111,24 @@ bool DynamicObject::Create(uint32 guidlow, Unit *caster, uint32 spellId, const P
|
||||
void DynamicObject::Update(uint32 p_time)
|
||||
{
|
||||
// caster has to be always avalible and in the same map
|
||||
ASSERT(m_caster);
|
||||
ASSERT(m_caster->GetMap() == GetMap());
|
||||
ASSERT(_caster);
|
||||
ASSERT(_caster->GetMap() == GetMap());
|
||||
|
||||
bool expired = false;
|
||||
|
||||
if (m_aura)
|
||||
if (_aura)
|
||||
{
|
||||
if (!m_aura->IsRemoved())
|
||||
m_aura->UpdateOwner(p_time, this);
|
||||
if (!_aura->IsRemoved())
|
||||
_aura->UpdateOwner(p_time, this);
|
||||
|
||||
// m_aura may be set to null in Aura::UpdateOwner call
|
||||
if (m_aura && (m_aura->IsRemoved() || m_aura->IsExpired()))
|
||||
if (_aura && (_aura->IsRemoved() || _aura->IsExpired()))
|
||||
expired = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetDuration() > int32(p_time))
|
||||
m_duration -= p_time;
|
||||
_duration -= p_time;
|
||||
else
|
||||
expired = true;
|
||||
}
|
||||
@@ -155,18 +151,18 @@ void DynamicObject::Remove()
|
||||
|
||||
int32 DynamicObject::GetDuration() const
|
||||
{
|
||||
if (!m_aura)
|
||||
return m_duration;
|
||||
if (!_aura)
|
||||
return _duration;
|
||||
else
|
||||
return m_aura->GetDuration();
|
||||
return _aura->GetDuration();
|
||||
}
|
||||
|
||||
void DynamicObject::SetDuration(int32 newDuration)
|
||||
{
|
||||
if (!m_aura)
|
||||
m_duration = newDuration;
|
||||
if (!_aura)
|
||||
_duration = newDuration;
|
||||
else
|
||||
m_aura->SetDuration(newDuration);
|
||||
_aura->SetDuration(newDuration);
|
||||
}
|
||||
|
||||
void DynamicObject::Delay(int32 delaytime)
|
||||
@@ -174,51 +170,51 @@ void DynamicObject::Delay(int32 delaytime)
|
||||
SetDuration(GetDuration() - delaytime);
|
||||
}
|
||||
|
||||
void DynamicObject::SetAura(Aura * aura)
|
||||
void DynamicObject::SetAura(Aura* aura)
|
||||
{
|
||||
ASSERT (!m_aura && aura);
|
||||
m_aura = aura;
|
||||
ASSERT(!_aura && aura);
|
||||
_aura = aura;
|
||||
}
|
||||
|
||||
void DynamicObject::RemoveAura()
|
||||
{
|
||||
ASSERT (m_aura);
|
||||
if (!m_aura->IsRemoved())
|
||||
m_aura->_Remove(AURA_REMOVE_BY_DEFAULT);
|
||||
delete m_aura;
|
||||
m_aura = NULL;
|
||||
ASSERT(_aura);
|
||||
if (!_aura->IsRemoved())
|
||||
_aura->_Remove(AURA_REMOVE_BY_DEFAULT);
|
||||
delete _aura;
|
||||
_aura = NULL;
|
||||
}
|
||||
|
||||
void DynamicObject::SetCasterViewpoint()
|
||||
{
|
||||
if (Player * caster = m_caster->ToPlayer())
|
||||
if (Player* caster = _caster->ToPlayer())
|
||||
{
|
||||
caster->SetViewpoint(this, true);
|
||||
m_isViewpoint = true;
|
||||
_isViewpoint = true;
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicObject::RemoveCasterViewpoint()
|
||||
{
|
||||
if (Player * caster = m_caster->ToPlayer())
|
||||
if (Player * caster = _caster->ToPlayer())
|
||||
{
|
||||
caster->SetViewpoint(this, false);
|
||||
m_isViewpoint = false;
|
||||
_isViewpoint = false;
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicObject::BindToCaster()
|
||||
{
|
||||
ASSERT(!m_caster);
|
||||
m_caster = ObjectAccessor::GetUnit(*this, GetCasterGUID());
|
||||
ASSERT(m_caster);
|
||||
ASSERT(m_caster->GetMap() == GetMap());
|
||||
m_caster->_RegisterDynObject(this);
|
||||
ASSERT(!_caster);
|
||||
_caster = ObjectAccessor::GetUnit(*this, GetCasterGUID());
|
||||
ASSERT(_caster);
|
||||
ASSERT(_caster->GetMap() == GetMap());
|
||||
_caster->_RegisterDynObject(this);
|
||||
}
|
||||
|
||||
void DynamicObject::UnbindFromCaster()
|
||||
{
|
||||
ASSERT(m_caster);
|
||||
m_caster->_UnregisterDynObject(this);
|
||||
m_caster = NULL;
|
||||
ASSERT(_caster);
|
||||
_caster->_UnregisterDynObject(this);
|
||||
_caster = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user