Core/Phasing: Implemented setting personal guid on PhaseShift

Port From (https://github.com/TrinityCore/TrinityCore/commit/ec9f5be6a657003a94f95b4e4067a37a9f113c7c)
This commit is contained in:
hondacrx
2021-03-04 12:30:02 -05:00
parent d7d4722d4b
commit 7b11540032
3 changed files with 45 additions and 7 deletions
+15 -4
View File
@@ -128,7 +128,6 @@ namespace Game
public void Clear()
{
ClearPhases();
PersonalGuid.Clear();
VisibleMapIds.Clear();
UiMapPhaseIds.Clear();
}
@@ -136,9 +135,11 @@ namespace Game
public void ClearPhases()
{
Flags &= PhaseShiftFlags.AlwaysVisible | PhaseShiftFlags.Inverse;
PersonalGuid.Clear();
Phases.Clear();
NonCosmeticReferences = 0;
CosmeticReferences = 0;
PersonalReferences = 0;
DefaultReferences = 0;
UpdateUnphasedFlag();
}
@@ -168,7 +169,6 @@ namespace Game
if (phaseShift.Flags.HasFlag(PhaseShiftFlags.Unphased) && !excludedPhaseShift.Flags.HasFlag(PhaseShiftFlags.InverseUnphased))
return true;
var list = excludedPhaseShift.Phases.ToList();
foreach (var pair in phaseShift.Phases)
{
if (pair.Value.Flags.HasAnyFlag(excludePhasesWithFlag))
@@ -201,12 +201,16 @@ namespace Game
else
DefaultReferences += references;
if (phaseRef.Flags.HasFlag(PhaseFlags.Personal))
PersonalReferences += references;
if (CosmeticReferences != 0)
Flags |= PhaseShiftFlags.NoCosmetic;
else
Flags &= ~PhaseShiftFlags.NoCosmetic;
UpdateUnphasedFlag();
UpdatePersonalGuid();
}
}
@@ -220,6 +224,12 @@ namespace Game
Flags |= unphasedFlag;
}
void UpdatePersonalGuid()
{
if (PersonalReferences == 0)
PersonalGuid.Clear();
}
public bool HasPhase(uint phaseId) { return Phases.ContainsKey(phaseId); }
public Dictionary<uint, PhaseRef> GetPhases() { return Phases; }
@@ -227,9 +237,9 @@ namespace Game
public Dictionary<uint, VisibleMapIdRef> GetVisibleMapIds() { return VisibleMapIds; }
public bool HasUiWorldMapAreaIdSwap(uint uiWorldMapAreaId) { return UiMapPhaseIds.ContainsKey(uiWorldMapAreaId); }
public Dictionary<uint, UiMapPhaseIdRef> GetUiWorldMapAreaIdSwaps() { return UiMapPhaseIds; }
public Dictionary<uint, UiMapPhaseIdRef> GetUiMapPhaseIds() { return UiMapPhaseIds; }
public PhaseShiftFlags Flags;
public PhaseShiftFlags Flags = PhaseShiftFlags.Unphased;
public ObjectGuid PersonalGuid;
public Dictionary<uint, PhaseRef> Phases = new Dictionary<uint, PhaseRef>();
public Dictionary<uint, VisibleMapIdRef> VisibleMapIds = new Dictionary<uint, VisibleMapIdRef>();
@@ -237,6 +247,7 @@ namespace Game
int NonCosmeticReferences;
int CosmeticReferences;
public int PersonalReferences;
int DefaultReferences;
public bool IsDbPhaseShift;
}
+29 -2
View File
@@ -53,16 +53,24 @@ namespace Game
}
public static void AddPhase(WorldObject obj, uint phaseId, bool updateVisibility)
{
AddPhase(obj, phaseId, obj.GetGUID(), updateVisibility);
}
static void AddPhase(WorldObject obj, uint phaseId, ObjectGuid personalGuid, bool updateVisibility)
{
bool changed = obj.GetPhaseShift().AddPhase(phaseId, GetPhaseFlags(phaseId), null);
if (obj.GetPhaseShift().PersonalReferences != 0)
obj.GetPhaseShift().PersonalGuid = personalGuid;
Unit unit = obj.ToUnit();
if (unit)
{
unit.OnPhaseChange();
ForAllControlled(unit, controlled =>
{
AddPhase(controlled, phaseId, updateVisibility);
AddPhase(controlled, phaseId, personalGuid, updateVisibility);
});
unit.RemoveNotOwnSingleTargetAuras(true);
}
@@ -89,6 +97,11 @@ namespace Game
}
public static void AddPhaseGroup(WorldObject obj, uint phaseGroupId, bool updateVisibility)
{
AddPhaseGroup(obj, phaseGroupId, obj.GetGUID(), updateVisibility);
}
static void AddPhaseGroup(WorldObject obj, uint phaseGroupId, ObjectGuid personalGuid, bool updateVisibility)
{
var phasesInGroup = Global.DB2Mgr.GetPhasesForGroup(phaseGroupId);
if (phasesInGroup.Empty())
@@ -98,13 +111,16 @@ namespace Game
foreach (uint phaseId in phasesInGroup)
changed = obj.GetPhaseShift().AddPhase(phaseId, GetPhaseFlags(phaseId), null) || changed;
if (obj.GetPhaseShift().PersonalReferences != 0)
obj.GetPhaseShift().PersonalGuid = personalGuid;
Unit unit = obj.ToUnit();
if (unit)
{
unit.OnPhaseChange();
ForAllControlled(unit, controlled =>
{
AddPhaseGroup(controlled, phaseGroupId, updateVisibility);
AddPhaseGroup(controlled, phaseGroupId, personalGuid, updateVisibility);
});
unit.RemoveNotOwnSingleTargetAuras(true);
}
@@ -266,6 +282,9 @@ namespace Game
changed = phaseShift.AddPhase(phaseId, GetPhaseFlags(phaseId), null) || changed;
}
if (phaseShift.PersonalReferences != 0)
phaseShift.PersonalGuid = unit.GetGUID();
if (changed)
unit.OnPhaseChange();
@@ -277,6 +296,11 @@ namespace Game
if (changed)
unit.RemoveNotOwnSingleTargetAuras(true);
}
else
{
if (phaseShift.PersonalReferences != 0)
phaseShift.PersonalGuid = obj.GetGUID();
}
UpdateVisibilityIfNeeded(obj, true, changed);
}
@@ -360,6 +384,9 @@ namespace Game
}
}
if (phaseShift.PersonalReferences != 0)
phaseShift.PersonalGuid = obj.GetGUID();
changed = changed || !newSuppressions.Phases.Empty() || !newSuppressions.VisibleMapIds.Empty();
foreach (var pair in newSuppressions.Phases)
suppressedPhaseShift.AddPhase(pair.Key, pair.Value.Flags, pair.Value.AreaConditions, pair.Value.References);