Core/Phasing: Reduce differences between branches in GridNotifiers

Port From (https://github.com/TrinityCore/TrinityCore/commit/c3f385c48f5080e64b13b0f31864e20e04e531aa)
This commit is contained in:
hondacrx
2023-01-05 02:44:38 -05:00
parent 4dc96a801c
commit 40db25f49c
8 changed files with 208 additions and 179 deletions
@@ -2704,7 +2704,7 @@ namespace Game.Entities
public bool IsWithinDistInMap(Player player)
{
return IsInMap(player) && IsInPhase(player) && IsAtInteractDistance(player);
return IsInMap(player) && InSamePhase(player) && IsAtInteractDistance(player);
}
public SpellInfo GetSpellForLock(Player player)
+20 -10
View File
@@ -1269,7 +1269,7 @@ namespace Game.Entities
public virtual bool CanNeverSee(WorldObject obj)
{
return GetMap() != obj.GetMap() || !IsInPhase(obj);
return GetMap() != obj.GetMap() || !InSamePhase(obj);
}
public virtual bool CanAlwaysSee(WorldObject obj) { return false; }
@@ -2911,26 +2911,36 @@ namespace Game.Entities
return playerList;
}
public bool IsInPhase(WorldObject obj)
public PhaseShift GetPhaseShift() { return _phaseShift; }
public void SetPhaseShift(PhaseShift phaseShift) { _phaseShift = new PhaseShift(phaseShift); }
public PhaseShift GetSuppressedPhaseShift() { return _suppressedPhaseShift; }
public void SetSuppressedPhaseShift(PhaseShift phaseShift) { _suppressedPhaseShift = new PhaseShift(phaseShift); }
public bool InSamePhase(PhaseShift phaseShift)
{
return GetPhaseShift().CanSee(phaseShift);
}
public bool InSamePhase(WorldObject obj)
{
return GetPhaseShift().CanSee(obj.GetPhaseShift());
}
public static bool InSamePhase(WorldObject a, WorldObject b)
{
return a != null && b != null && a.IsInPhase(b);
return a != null && b != null && a.InSamePhase(b);
}
public virtual float GetCombatReach() { return 0.0f; } // overridden (only) in Unit
public PhaseShift GetPhaseShift() { return _phaseShift; }
public void SetPhaseShift(PhaseShift phaseShift) { _phaseShift = new PhaseShift(phaseShift); }
public PhaseShift GetSuppressedPhaseShift() { return _suppressedPhaseShift; }
public void SetSuppressedPhaseShift(PhaseShift phaseShift) { _suppressedPhaseShift = new PhaseShift(phaseShift); }
public int GetDBPhase() { return _dbPhase; }
// if negative it is used as PhaseGroupId
public void SetDBPhase(int p) { _dbPhase = p; }
public virtual float GetCombatReach() { return 0.0f; } // overridden (only) in Unit
public void PlayDistanceSound(uint soundId, Player target = null)
{
PlaySpeakerBoxSound playSpeakerBoxSound = new(GetGUID(), soundId);
@@ -3228,7 +3238,7 @@ namespace Game.Entities
public bool IsWithinDistInMap(WorldObject obj, float dist2compare, bool is3D = true, bool incOwnRadius = true, bool incTargetRadius = true)
{
return obj && IsInMap(obj) && IsInPhase(obj) && _IsWithinDist(obj, dist2compare, is3D, incOwnRadius, incTargetRadius);
return obj && IsInMap(obj) && InSamePhase(obj) && _IsWithinDist(obj, dist2compare, is3D, incOwnRadius, incTargetRadius);
}
public bool IsWithinLOS(float ox, float oy, float oz, LineOfSightChecks checks = LineOfSightChecks.All, ModelIgnoreFlags ignoreFlags = ModelIgnoreFlags.Nothing)
+2 -2
View File
@@ -691,7 +691,7 @@ namespace Game.Entities
foreach (var player in GetMap().GetPlayers())
{
if (player.GetTransport() != this && player.IsInPhase(this))
if (player.GetTransport() != this && player.InSamePhase(this))
{
UpdateData data = new(GetMap().GetId());
BuildCreateUpdateBlockForPlayer(data, player);
@@ -761,7 +761,7 @@ namespace Game.Entities
return;
foreach (var playerReference in players)
if (playerReference.IsInPhase(this))
if (playerReference.InSamePhase(this))
BuildFieldsUpdate(playerReference, data_map);
ClearUpdateMask(true);
+1 -1
View File
@@ -1467,7 +1467,7 @@ namespace Game.Entities
public bool IsWithinMeleeRangeAt(Position pos, Unit obj)
{
if (!obj || !IsInMap(obj) || !IsInPhase(obj))
if (!obj || !IsInMap(obj) || !InSamePhase(obj))
return false;
float dx = pos.GetPositionX() - obj.GetPositionX();
+2 -2
View File
@@ -679,7 +679,7 @@ namespace Game.Entities
public bool IsWithinBoundaryRadius(Unit obj)
{
if (!obj || !IsInMap(obj) || !IsInPhase(obj))
if (!obj || !IsInMap(obj) || !InSamePhase(obj))
return false;
float objBoundaryRadius = Math.Max(obj.GetBoundingRadius(), SharedConst.MinMeleeReach);
@@ -1110,7 +1110,7 @@ namespace Game.Entities
public bool IsWithinCombatRange(Unit obj, float dist2compare)
{
if (!obj || !IsInMap(obj) || !IsInPhase(obj))
if (!obj || !IsInMap(obj) || !InSamePhase(obj))
return false;
float dx = GetPositionX() - obj.GetPositionX();
+2 -2
View File
@@ -3094,7 +3094,7 @@ namespace Game.Entities
else
{
Unit caster = aura.GetCaster();
if (!caster || !caster.IsInPhase(this))
if (!caster || !caster.InSamePhase(this))
RemoveOwnedAura(pair);
}
}
@@ -3104,7 +3104,7 @@ namespace Game.Entities
for (var i = 0; i < m_scAuras.Count; i++)
{
var aura = m_scAuras[i];
if (aura.GetUnitOwner() != this && (!onPhaseChange || !aura.GetUnitOwner().IsInPhase(this)))
if (aura.GetUnitOwner() != this && (!onPhaseChange || !aura.GetUnitOwner().InSamePhase(this)))
aura.Remove();
}
}