Core/Entities: Phasing rewrite

This commit is contained in:
hondacrx
2018-03-28 11:09:30 -04:00
parent caad52f636
commit fa35d60f60
72 changed files with 2254 additions and 1146 deletions
+4 -4
View File
@@ -64,11 +64,11 @@ namespace Game.Entities
}
public virtual bool IsInWater()
{
return GetMap().IsInWater(GetPositionX(), GetPositionY(), GetPositionZ());
return GetMap().IsInWater(GetPhaseShift(), GetPositionX(), GetPositionY(), GetPositionZ());
}
public virtual bool IsUnderWater()
{
return GetMap().IsUnderWater(GetPositionX(), GetPositionY(), GetPositionZ());
return GetMap().IsUnderWater(GetPhaseShift(), GetPositionX(), GetPositionY(), GetPositionZ());
}
void propagateSpeedChange() { GetMotionMaster().propagateSpeedChange(); }
@@ -677,7 +677,7 @@ namespace Game.Entities
}
LiquidData liquid;
ZLiquidStatus liquidStatus = GetMap().getLiquidStatus(GetPositionX(), GetPositionY(), GetPositionZ(), MapConst.MapAllLiquidTypes, out liquid);
ZLiquidStatus liquidStatus = GetMap().getLiquidStatus(GetPhaseShift(), GetPositionX(), GetPositionY(), GetPositionZ(), MapConst.MapAllLiquidTypes, out liquid);
isSubmerged = liquidStatus.HasAnyFlag(ZLiquidStatus.UnderWater) || HasUnitMovementFlag(MovementFlag.Swimming);
isInWater = liquidStatus.HasAnyFlag(ZLiquidStatus.InWater | ZLiquidStatus.UnderWater);
@@ -748,7 +748,7 @@ namespace Game.Entities
return;
LiquidData liquid_status;
ZLiquidStatus res = m.getLiquidStatus(x, y, z, MapConst.MapAllLiquidTypes, out liquid_status);
ZLiquidStatus res = m.getLiquidStatus(GetPhaseShift(), x, y, z, MapConst.MapAllLiquidTypes, out liquid_status);
if (res == 0)
{
if (_lastLiquid != null && _lastLiquid.SpellID != 0)
+1 -1
View File
@@ -784,7 +784,7 @@ namespace Game.Entities
return false;
}
pet.CopyPhaseFrom(this);
PhasingHandler.InheritPhaseShift(pet, this);
pet.GetCharmInfo().SetPetNumber(Global.ObjectMgr.GeneratePetNumber(), true);
// this enables pet details window (Shift+P)
+4 -4
View File
@@ -3313,7 +3313,7 @@ namespace Game.Entities
}
}
}
public void RemoveNotOwnSingleTargetAuras(uint newPhase = 0, bool phaseid = false)
public void RemoveNotOwnSingleTargetAuras(bool onPhaseChange = false)
{
// Iterate m_ownedAuras - aura is marked as single target in Unit::AddAura (and pushed to m_ownedAuras).
// m_appliedAuras will NOT contain the aura before first Unit::Update after adding it to m_ownedAuras.
@@ -3330,12 +3330,12 @@ namespace Game.Entities
if (aura.GetCasterGUID() != GetGUID() && aura.IsSingleTarget())
{
if (newPhase == 0 && !phaseid)
if (onPhaseChange)
RemoveOwnedAura(list[i]);
else
{
Unit caster = aura.GetCaster();
if (!caster || (newPhase != 0 && !caster.IsInPhase(newPhase)) || (newPhase == 0 && !caster.IsInPhase(this)))
if (!caster || !caster.IsInPhase(this))
RemoveOwnedAura(list[i]);
}
}
@@ -3345,7 +3345,7 @@ namespace Game.Entities
for (var i = 0; i < m_scAuras.Count; i++)
{
var aura = m_scAuras[i];
if (aura.GetUnitOwner() != this && !aura.GetUnitOwner().IsInPhase(newPhase))
if (aura.GetUnitOwner() != this && (!onPhaseChange || !aura.GetUnitOwner().IsInPhase(this)))
aura.Remove();
}
}
+5 -34
View File
@@ -416,15 +416,6 @@ namespace Game.Entities
}
}
public override void AddToWorld()
{
if (!IsInWorld)
{
base.AddToWorld();
}
RebuildTerrainSwaps();
}
public override void RemoveFromWorld()
{
// cleanup
@@ -935,7 +926,7 @@ namespace Game.Entities
MoveSplineInit init = new MoveSplineInit(this);
// Creatures without inhabit type air should begin falling after exiting the vehicle
if (IsTypeId(TypeId.Unit) && !ToCreature().CanFly() && height > GetMap().GetWaterOrGroundLevel(GetPhases(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), ref height) + 0.1f)
if (IsTypeId(TypeId.Unit) && !ToCreature().CanFly() && height > GetMap().GetWaterOrGroundLevel(GetPhaseShift(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), ref height) + 0.1f)
init.SetFall();
init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), height, false);
@@ -1099,14 +1090,12 @@ namespace Game.Entities
public HostileRefManager getHostileRefManager() { return m_HostileRefManager; }
public override bool SetInPhase(uint id, bool update, bool apply)
public void OnPhaseChange()
{
bool res = base.SetInPhase(id, update, apply);
if (!IsInWorld)
return res;
return;
if (IsTypeId(TypeId.Unit) || (!ToPlayer().IsGameMaster() && !ToPlayer().GetSession().PlayerLogout()))
if (IsTypeId(TypeId.Unit) || !ToPlayer().GetSession().PlayerLogout())
{
HostileRefManager refManager = getHostileRefManager();
HostileReference refe = refManager.getFirst();
@@ -1143,26 +1132,8 @@ namespace Game.Entities
}
}
}
foreach (var unit in m_Controlled)
if (unit.IsTypeId(TypeId.Unit))
unit.SetInPhase(id, true, apply);
for (byte i = 0; i < SharedConst.MaxSummonSlot; ++i)
{
if (!m_SummonSlot[i].IsEmpty())
{
Creature summon = GetMap().GetCreature(m_SummonSlot[i]);
if (summon != null)
summon.SetInPhase(id, true, apply);
}
}
RemoveNotOwnSingleTargetAuras(0, true);
return res;
}
public uint GetModelForForm(ShapeShiftForm form)
{
if (IsTypeId(TypeId.Player))