Add intermediary SpellCaster class to hold common parts of Unit and GameObject.

This commit is contained in:
ratkosrb
2021-04-24 04:42:03 +03:00
parent c04288b2c5
commit b2c5ba5789
23 changed files with 2876 additions and 2864 deletions
+2 -7
View File
@@ -121,7 +121,7 @@ bool DynamicObject::Create(uint32 guidlow, WorldObject* caster, uint32 spellId,
return true;
}
WorldObject* DynamicObject::GetCaster() const
SpellCaster* DynamicObject::GetCaster() const
{
if (ObjectGuid guid = GetCasterGuid())
{
@@ -160,16 +160,11 @@ uint32 DynamicObject::GetFactionTemplateId() const
return GetCaster()->GetFactionTemplateId();
}
uint32 DynamicObject::GetLevel() const
{
return GetCaster()->GetLevel();
}
void DynamicObject::Update(uint32 update_diff, uint32 p_time)
{
WorldObject::Update(update_diff, p_time);
// caster can be not in world at time dynamic object update, but dynamic object not yet deleted in Unit destructor
WorldObject* caster = GetCaster();
SpellCaster* caster = GetCaster();
if (!caster)
{
Delete();