Some refactoring of code. and some cleanups
This commit is contained in:
@@ -39,17 +39,14 @@ namespace Game.Entities
|
||||
return m_movementInfo.HasMovementFlag(MovementFlag.Walking);
|
||||
}
|
||||
bool IsHovering() { return m_movementInfo.HasMovementFlag(MovementFlag.Hover); }
|
||||
public bool isStopped()
|
||||
{
|
||||
return !(HasUnitState(UnitState.Moving));
|
||||
}
|
||||
public bool isMoving() { return m_movementInfo.HasMovementFlag(MovementFlag.MaskMoving); }
|
||||
public bool isTurning() { return m_movementInfo.HasMovementFlag(MovementFlag.MaskTurning); }
|
||||
public bool IsStopped() { return !HasUnitState(UnitState.Moving); }
|
||||
public bool IsMoving() { return m_movementInfo.HasMovementFlag(MovementFlag.MaskMoving); }
|
||||
public bool IsTurning() { return m_movementInfo.HasMovementFlag(MovementFlag.MaskTurning); }
|
||||
public virtual bool CanFly() { return false; }
|
||||
public bool IsFlying() { return m_movementInfo.HasMovementFlag(MovementFlag.Flying | MovementFlag.DisableGravity); }
|
||||
public bool IsFalling()
|
||||
{
|
||||
return m_movementInfo.HasMovementFlag(MovementFlag.Falling | MovementFlag.FallingFar) || moveSpline.isFalling();
|
||||
return m_movementInfo.HasMovementFlag(MovementFlag.Falling | MovementFlag.FallingFar) || MoveSpline.isFalling();
|
||||
}
|
||||
public virtual bool CanSwim()
|
||||
{
|
||||
@@ -71,7 +68,7 @@ namespace Game.Entities
|
||||
return GetMap().IsUnderWater(GetPhaseShift(), GetPositionX(), GetPositionY(), GetPositionZ());
|
||||
}
|
||||
|
||||
void propagateSpeedChange() { GetMotionMaster().propagateSpeedChange(); }
|
||||
void PropagateSpeedChange() { GetMotionMaster().propagateSpeedChange(); }
|
||||
|
||||
public float GetSpeed(UnitMoveType mtype)
|
||||
{
|
||||
@@ -92,7 +89,7 @@ namespace Game.Entities
|
||||
|
||||
m_speed_rate[(int)mtype] = rate;
|
||||
|
||||
propagateSpeedChange();
|
||||
PropagateSpeedChange();
|
||||
|
||||
// Spline packets are for creatures and move_update are for players
|
||||
ServerOpcodes[,] moveTypeToOpcode = new ServerOpcodes[(int)UnitMoveType.Max, 3]
|
||||
@@ -154,7 +151,7 @@ namespace Game.Entities
|
||||
ClearUnitState(UnitState.Moving);
|
||||
|
||||
// not need send any packets if not in world or not moving
|
||||
if (!IsInWorld || moveSpline.Finalized())
|
||||
if (!IsInWorld || MoveSpline.Finalized())
|
||||
return;
|
||||
|
||||
MoveSplineInit init = new MoveSplineInit(this);
|
||||
@@ -608,7 +605,7 @@ namespace Game.Entities
|
||||
if (combat_reach < 0.1f)
|
||||
combat_reach = SharedConst.DefaultCombatReach;
|
||||
|
||||
int attacker_number = getAttackers().Count;
|
||||
int attacker_number = GetAttackers().Count;
|
||||
if (attacker_number > 0)
|
||||
--attacker_number;
|
||||
GetNearPoint(obj, out x, out y, out z, obj.GetCombatReach(), distance2dMin + (distance2dMax - distance2dMin) * (float)RandomHelper.NextDouble()
|
||||
@@ -1014,16 +1011,16 @@ namespace Game.Entities
|
||||
return distsq < maxdist * maxdist;
|
||||
}
|
||||
|
||||
public bool isInFrontInMap(Unit target, float distance, float arc = MathFunctions.PI)
|
||||
public bool IsInFrontInMap(Unit target, float distance, float arc = MathFunctions.PI)
|
||||
{
|
||||
return IsWithinDistInMap(target, distance) && HasInArc(arc, target);
|
||||
}
|
||||
|
||||
public bool isInBackInMap(Unit target, float distance, float arc = MathFunctions.PI)
|
||||
public bool IsInBackInMap(Unit target, float distance, float arc = MathFunctions.PI)
|
||||
{
|
||||
return IsWithinDistInMap(target, distance) && !HasInArc(MathFunctions.TwoPi - arc, target);
|
||||
}
|
||||
public bool isInAccessiblePlaceFor(Creature c)
|
||||
public bool IsInAccessiblePlaceFor(Creature c)
|
||||
{
|
||||
if (IsInWater())
|
||||
return c.CanSwim();
|
||||
@@ -1220,7 +1217,7 @@ namespace Game.Entities
|
||||
if (!fearAuras.Empty())
|
||||
caster = Global.ObjAccessor.GetUnit(this, fearAuras[0].GetCasterGUID());
|
||||
if (caster == null)
|
||||
caster = getAttackerForHelper();
|
||||
caster = GetAttackerForHelper();
|
||||
GetMotionMaster().MoveFleeing(caster, (uint)(fearAuras.Empty() ? WorldConfig.GetIntValue(WorldCfg.CreatureFamilyFleeDelay) : 0)); // caster == NULL processed in MoveFleeing
|
||||
}
|
||||
else
|
||||
@@ -1370,9 +1367,9 @@ namespace Game.Entities
|
||||
if (vehInfo == null)
|
||||
return false;
|
||||
|
||||
m_vehicleKit = new Vehicle(this, vehInfo, creatureEntry);
|
||||
VehicleKit = new Vehicle(this, vehInfo, creatureEntry);
|
||||
m_updateFlag.Vehicle = true;
|
||||
m_unitTypeMask |= UnitTypeMask.Vehicle;
|
||||
UnitTypeMask |= UnitTypeMask.Vehicle;
|
||||
|
||||
if (!loading)
|
||||
SendSetVehicleRecId(id);
|
||||
@@ -1382,18 +1379,18 @@ namespace Game.Entities
|
||||
|
||||
public void RemoveVehicleKit(bool onRemoveFromWorld = false)
|
||||
{
|
||||
if (m_vehicleKit == null)
|
||||
if (VehicleKit == null)
|
||||
return;
|
||||
|
||||
if (!onRemoveFromWorld)
|
||||
SendSetVehicleRecId(0);
|
||||
|
||||
m_vehicleKit.Uninstall();
|
||||
VehicleKit.Uninstall();
|
||||
|
||||
m_vehicleKit = null;
|
||||
VehicleKit = null;
|
||||
|
||||
m_updateFlag.Vehicle = false;
|
||||
m_unitTypeMask &= ~UnitTypeMask.Vehicle;
|
||||
UnitTypeMask &= ~UnitTypeMask.Vehicle;
|
||||
RemoveNpcFlag(NPCFlags.SpellClick | NPCFlags.PlayerVehicle);
|
||||
}
|
||||
|
||||
@@ -1630,17 +1627,17 @@ namespace Game.Entities
|
||||
//Spline
|
||||
public bool IsSplineEnabled()
|
||||
{
|
||||
return moveSpline.Initialized() && !moveSpline.Finalized();
|
||||
return MoveSpline.Initialized() && !MoveSpline.Finalized();
|
||||
}
|
||||
void UpdateSplineMovement(uint diff)
|
||||
{
|
||||
int positionUpdateDelay = 400;
|
||||
|
||||
if (moveSpline.Finalized())
|
||||
if (MoveSpline.Finalized())
|
||||
return;
|
||||
|
||||
moveSpline.updateState((int)diff);
|
||||
bool arrived = moveSpline.Finalized();
|
||||
MoveSpline.updateState((int)diff);
|
||||
bool arrived = MoveSpline.Finalized();
|
||||
|
||||
if (arrived)
|
||||
DisableSpline();
|
||||
@@ -1649,13 +1646,13 @@ namespace Game.Entities
|
||||
if (movesplineTimer.Passed() || arrived)
|
||||
{
|
||||
movesplineTimer.Reset(positionUpdateDelay);
|
||||
Vector4 loc = moveSpline.ComputePosition();
|
||||
Vector4 loc = MoveSpline.ComputePosition();
|
||||
float x = loc.X;
|
||||
float y = loc.Y;
|
||||
float z = loc.Z;
|
||||
float o = loc.W;
|
||||
|
||||
if (moveSpline.onTransport)
|
||||
if (MoveSpline.onTransport)
|
||||
{
|
||||
m_movementInfo.transport.pos.Relocate(x, y, z, o);
|
||||
|
||||
@@ -1672,7 +1669,7 @@ namespace Game.Entities
|
||||
public void DisableSpline()
|
||||
{
|
||||
m_movementInfo.RemoveMovementFlag(MovementFlag.Forward);
|
||||
moveSpline.Interrupt();
|
||||
MoveSpline.Interrupt();
|
||||
}
|
||||
|
||||
//Transport
|
||||
|
||||
Reference in New Issue
Block a user