Core/Phasing: Implemented setting personal guid on PhaseShift

This commit is contained in:
Shauren
2021-02-27 01:44:44 +01:00
parent c9344c145a
commit ec9f5be6a6
5 changed files with 66 additions and 26 deletions

View File

@@ -55,23 +55,31 @@ inline void ForAllControlled(Unit* unit, Func&& func)
if (controlled->GetTypeId() != TYPEID_PLAYER)
func(controlled);
for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i)
if (!unit->m_SummonSlot[i].IsEmpty())
if (Creature* summon = unit->GetMap()->GetCreature(unit->m_SummonSlot[i]))
for (ObjectGuid summonGuid : unit->m_SummonSlot)
if (!summonGuid.IsEmpty())
if (Creature* summon = unit->GetMap()->GetCreature(summonGuid))
func(summon);
}
}
void PhasingHandler::AddPhase(WorldObject* object, uint32 phaseId, bool updateVisibility)
{
AddPhase(object, phaseId, object->GetGUID(), updateVisibility);
}
void PhasingHandler::AddPhase(WorldObject* object, uint32 phaseId, ObjectGuid const& personalGuid, bool updateVisibility)
{
bool changed = object->GetPhaseShift().AddPhase(phaseId, GetPhaseFlags(phaseId), nullptr);
if (object->GetPhaseShift().PersonalReferences)
object->GetPhaseShift().PersonalGuid = personalGuid;
if (Unit* unit = object->ToUnit())
{
unit->OnPhaseChange();
ForAllControlled(unit, [&](Unit* controlled)
{
AddPhase(controlled, phaseId, updateVisibility);
AddPhase(controlled, phaseId, personalGuid, updateVisibility);
});
unit->RemoveNotOwnSingleTargetAuras(true);
}
@@ -97,6 +105,11 @@ void PhasingHandler::RemovePhase(WorldObject* object, uint32 phaseId, bool updat
}
void PhasingHandler::AddPhaseGroup(WorldObject* object, uint32 phaseGroupId, bool updateVisibility)
{
AddPhaseGroup(object, phaseGroupId, object->GetGUID(), updateVisibility);
}
void PhasingHandler::AddPhaseGroup(WorldObject* object, uint32 phaseGroupId, ObjectGuid const& personalGuid, bool updateVisibility)
{
std::vector<uint32> const* phasesInGroup = sDB2Manager.GetPhasesForGroup(phaseGroupId);
if (!phasesInGroup)
@@ -106,12 +119,15 @@ void PhasingHandler::AddPhaseGroup(WorldObject* object, uint32 phaseGroupId, boo
for (uint32 phaseId : *phasesInGroup)
changed = object->GetPhaseShift().AddPhase(phaseId, GetPhaseFlags(phaseId), nullptr) || changed;
if (object->GetPhaseShift().PersonalReferences)
object->GetPhaseShift().PersonalGuid = personalGuid;
if (Unit* unit = object->ToUnit())
{
unit->OnPhaseChange();
ForAllControlled(unit, [&](Unit* controlled)
{
AddPhaseGroup(controlled, phaseGroupId, updateVisibility);
AddPhaseGroup(controlled, phaseGroupId, personalGuid, updateVisibility);
});
unit->RemoveNotOwnSingleTargetAuras(true);
}
@@ -269,6 +285,9 @@ void PhasingHandler::OnAreaChange(WorldObject* object)
for (uint32 phaseId : *phasesInGroup)
changed = phaseShift.AddPhase(phaseId, GetPhaseFlags(phaseId), nullptr) || changed;
if (phaseShift.PersonalReferences)
phaseShift.PersonalGuid = unit->GetGUID();
if (changed)
unit->OnPhaseChange();
@@ -280,6 +299,11 @@ void PhasingHandler::OnAreaChange(WorldObject* object)
if (changed)
unit->RemoveNotOwnSingleTargetAuras(true);
}
else
{
if (phaseShift.PersonalReferences)
phaseShift.PersonalGuid = object->GetGUID();
}
UpdateVisibilityIfNeeded(object, true, changed);
}
@@ -371,12 +395,15 @@ void PhasingHandler::OnConditionChange(WorldObject* object)
}
}
changed = changed || !newSuppressions.Phases.empty() || !newSuppressions.VisibleMapIds.empty();
for (auto itr = newSuppressions.Phases.begin(); itr != newSuppressions.Phases.end(); ++itr)
suppressedPhaseShift.AddPhase(itr->Id, itr->Flags, itr->AreaConditions, itr->References);
if (phaseShift.PersonalReferences)
phaseShift.PersonalGuid = object->GetGUID();
for (auto itr = newSuppressions.VisibleMapIds.begin(); itr != newSuppressions.VisibleMapIds.end(); ++itr)
suppressedPhaseShift.AddVisibleMapId(itr->first, itr->second.VisibleMapInfo, itr->second.References);
changed = changed || !newSuppressions.Phases.empty() || !newSuppressions.VisibleMapIds.empty();
for (PhaseShift::PhaseRef const& phaseRef : newSuppressions.Phases)
suppressedPhaseShift.AddPhase(phaseRef.Id, phaseRef.Flags, phaseRef.AreaConditions, phaseRef.References);
for (std::pair<uint32 const, PhaseShift::VisibleMapIdRef> const& visibleMap : newSuppressions.VisibleMapIds)
suppressedPhaseShift.AddVisibleMapId(visibleMap.first, visibleMap.second.VisibleMapInfo, visibleMap.second.References);
if (unit)
{