Core/Creatures: moved summon AI hooks to SummonInfo API
This commit is contained in:
1 parent
a4551319fe
commit
73effb91ad
3 files changed
+20
-16
No files matched your search
@@ -337,17 +337,11 @@ void Creature::RemoveFromWorld()
|
||||
// If the creature about to despawn, unregister it for the summoner
|
||||
if (SummonInfo* summonInfo = GetSummonInfo())
|
||||
{
|
||||
if (Unit* summoner = summonInfo->GetUnitSummoner())
|
||||
{
|
||||
summoner->UnregisterSummon(summonInfo);
|
||||
// Perform cleanup actions if needed
|
||||
summonInfo->HandlePreUnsummonActions();
|
||||
|
||||
if (summonInfo->GetControl() == SummonPropertiesControl::Pet)
|
||||
{
|
||||
summoner->SetPetGUID(ObjectGuid::Empty);
|
||||
//if (Player* playerSummoner = summoner->ToPlayer())
|
||||
// playerSummoner->SendRemoveControlBar();
|
||||
}
|
||||
}
|
||||
if (Unit* summoner = summonInfo->GetUnitSummoner())
|
||||
summoner->UnregisterSummon(summonInfo);
|
||||
}
|
||||
|
||||
if (GetZoneScript())
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "CharmInfo.h"
|
||||
#include "Creature.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "DBCEnums.h"
|
||||
#include "DBCStores.h"
|
||||
#include "Log.h"
|
||||
@@ -156,10 +157,12 @@ void SummonInfo::HandlePreSummonActions()
|
||||
|
||||
void SummonInfo::HandlePostSummonActions()
|
||||
{
|
||||
// Register Pet and enable its control
|
||||
if (_control == SummonPropertiesControl::Pet)
|
||||
Unit* summoner = GetUnitSummoner();
|
||||
|
||||
if (summoner)
|
||||
{
|
||||
if (Unit* summoner = GetUnitSummoner())
|
||||
// Register Pet and enable its control
|
||||
if (_control == SummonPropertiesControl::Pet)
|
||||
{
|
||||
_summonedCreature->SetOwnerGUID(summoner->GetGUID());
|
||||
|
||||
@@ -176,6 +179,13 @@ void SummonInfo::HandlePostSummonActions()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Infoke JustSummoned and IsSummonedBy AI hooks
|
||||
if (summoner->IsCreature() && summoner->IsAIEnabled())
|
||||
summoner->ToCreature()->AI()->JustSummoned(_summonedCreature);
|
||||
|
||||
if (_summonedCreature->IsAIEnabled())
|
||||
_summonedCreature->AI()->IsSummonedBy(summoner);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,6 +202,9 @@ void SummonInfo::HandlePreUnsummonActions()
|
||||
if (Player* player = summoner->ToPlayer())
|
||||
player->SendRemoveControlBar();
|
||||
}
|
||||
|
||||
if (summoner->IsCreature() && summoner->IsAIEnabled())
|
||||
summoner->ToCreature()->AI()->SummonedCreatureDespawn(_summonedCreature);
|
||||
}
|
||||
|
||||
void SummonInfo::UpdateRemainingDuration(Milliseconds deltaTime)
|
||||
|
||||
@@ -8863,9 +8863,6 @@ void Unit::UnregisterSummon(SummonInfo* summon)
|
||||
if (!summon)
|
||||
return;
|
||||
|
||||
// Perform cleanup actions if needed
|
||||
summon->HandlePreUnsummonActions();
|
||||
|
||||
SummonPropertiesSlot slot = summon->GetSummonSlot();
|
||||
if (slot == SummonPropertiesSlot::None)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user