Skip to content

Commit

Permalink
Instance/GO: Implement OnObjectDespawn
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Dec 29, 2023
1 parent 1591e56 commit f5b08d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/game/Entities/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,9 @@ void GameObject::Update(const uint32 diff)
if (AI())
AI()->JustDespawned();

if (InstanceData* iData = GetMap()->GetInstanceData())
iData->OnObjectDespawn(this);

if (!m_respawnOverriden)
{
// since pool system can fail to roll unspawned object, this one can remain spawned, so must set respawn nevertheless
Expand Down Expand Up @@ -788,6 +791,9 @@ void GameObject::Delete()
if (AI())
AI()->JustDespawned();

if (InstanceData* iData = GetMap()->GetInstanceData())
iData->OnObjectDespawn(this);

if (uint16 poolid = sPoolMgr.IsPartOfAPool<GameObject>(GetDbGuid()))
sPoolMgr.UpdatePool<GameObject>(*GetMap()->GetPersistentState(), poolid, GetDbGuid());
else
Expand Down
3 changes: 3 additions & 0 deletions src/game/Maps/InstanceData.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ class InstanceData
// Called when a gameobject is spawned into map
virtual void OnObjectSpawn(GameObject*) {}

// Called when a gameobject is despawned from map
virtual void OnObjectDespawn(GameObject*) {}

// called on creature creation
virtual void OnCreatureCreate(Creature* /*creature*/) {}

Expand Down

0 comments on commit f5b08d9

Please sign in to comment.