Some refactoring of code. and some cleanups

This commit is contained in:
hondacrx
2019-09-21 12:11:16 -04:00
parent 7c405230cc
commit 35c06c09fd
214 changed files with 1235 additions and 1341 deletions
@@ -79,7 +79,7 @@ namespace Game.Movement
// currently moving, update location
owner.AddUnitState(UnitState.ConfusedMove);
if (owner.moveSpline.Finalized())
if (owner.MoveSpline.Finalized())
i_nextMoveTime.Reset(RandomHelper.IRand(800, 1500));
}
else
@@ -161,7 +161,7 @@ namespace Game.Movement
}
i_nextCheckTime.Update(time_diff);
if (i_nextCheckTime.Passed() && owner.moveSpline.Finalized())
if (i_nextCheckTime.Passed() && owner.MoveSpline.Finalized())
_setTargetLocation(owner);
return true;
@@ -44,7 +44,7 @@ namespace Game.AI
public override bool DoUpdate(T owner, uint time_diff)
{
arrived = skipToHome || owner.moveSpline.Finalized();
arrived = skipToHome || owner.MoveSpline.Finalized();
return !arrived;
}
@@ -31,7 +31,7 @@ namespace Game.Movement
public override void Reset(Unit owner)
{
if (!owner.isStopped())
if (!owner.IsStopped())
owner.StopMoving();
}
public override void Initialize(Unit owner)
@@ -75,12 +75,12 @@ namespace Game.Movement
{
public override void targetObjectBuildLink()
{
getTarget().addFollower(this);
getTarget().AddFollower(this);
}
public override void targetObjectDestroyLink()
{
getTarget().removeFollower(this);
getTarget().RemoveFollower(this);
}
public override void sourceObjectDestroyLink()
@@ -20,7 +20,6 @@ using Framework.GameMath;
using Game.Entities;
using Game.Maps;
using System;
using System.Linq;
namespace Game.Movement
{
@@ -61,7 +61,7 @@ namespace Game.Movement
// Call for creature group update
Creature creature = owner.ToCreature();
if (creature != null)
if (creature.GetFormation() != null && creature.GetFormation().getLeader() == creature)
if (creature.GetFormation() != null && creature.GetFormation().GetLeader() == creature)
creature.GetFormation().LeaderMoveTo(i_x, i_y, i_z);
}
@@ -78,7 +78,7 @@ namespace Game.Movement
owner.AddUnitState(UnitState.RoamingMove);
if (id != EventId.ChargePrepath && i_recalculateSpeed && !owner.moveSpline.Finalized())
if (id != EventId.ChargePrepath && i_recalculateSpeed && !owner.MoveSpline.Finalized())
{
i_recalculateSpeed = false;
MoveSplineInit init = new MoveSplineInit(owner);
@@ -90,11 +90,11 @@ namespace Game.Movement
// Call for creature group update
Creature creature = owner.ToCreature();
if (creature != null)
if (creature.GetFormation() != null && creature.GetFormation().getLeader() == creature)
if (creature.GetFormation() != null && creature.GetFormation().GetLeader() == creature)
creature.GetFormation().LeaderMoveTo(i_x, i_y, i_z);
}
return !owner.moveSpline.Finalized();
return !owner.MoveSpline.Finalized();
}
public override void DoFinalize(T owner)
@@ -102,7 +102,7 @@ namespace Game.Movement
if (!owner.HasUnitState(UnitState.Charging))
owner.ClearUnitState(UnitState.Roaming | UnitState.RoamingMove);
if (owner.moveSpline.Finalized())
if (owner.MoveSpline.Finalized())
MovementInform(owner);
}
@@ -160,7 +160,7 @@ namespace Game.Movement
// Does almost nothing - just doesn't allows previous movegen interrupt current effect.
public class EffectMovementGenerator : IMovementGenerator
{
public EffectMovementGenerator(uint Id, uint arrivalSpellId = 0, ObjectGuid arrivalSpellTargetGuid = default(ObjectGuid))
public EffectMovementGenerator(uint Id, uint arrivalSpellId = 0, ObjectGuid arrivalSpellTargetGuid = default)
{
_Id = Id;
_arrivalSpellId = arrivalSpellId;
@@ -191,7 +191,7 @@ namespace Game.Movement
public override bool Update(Unit owner, uint time_diff)
{
return !owner.moveSpline.Finalized();
return !owner.MoveSpline.Finalized();
}
public override void Initialize(Unit owner) { }
@@ -75,7 +75,7 @@ namespace Game.Movement
return true;
}
if (creature.moveSpline.Finalized())
if (creature.MoveSpline.Finalized())
{
i_nextMoveTime.Update((int)diff);
if (i_nextMoveTime.Passed())
@@ -167,7 +167,7 @@ namespace Game.Movement
init.Launch();
//Call for creature group update
if (creature.GetFormation() != null && creature.GetFormation().getLeader() == creature)
if (creature.GetFormation() != null && creature.GetFormation().GetLeader() == creature)
creature.GetFormation().LeaderMoveTo(destX, destY, destZ);
}
@@ -20,7 +20,6 @@ using Framework.GameMath;
using Game.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Game.Movement
{
@@ -131,7 +130,7 @@ namespace Game.Movement
// _msToNext being zero here means we're on the final spline
if (_msToNext == 0)
{
finished = me.moveSpline.Finalized();
finished = me.MoveSpline.Finalized();
return !finished;
}
@@ -158,14 +157,14 @@ namespace Game.Movement
{
if (_nextIndex == 0)
return new SplineChainResumeInfo(_id, _chain, _walk, 0, 0, _msToNext);
if (me.moveSpline.Finalized())
if (me.MoveSpline.Finalized())
{
if (_nextIndex < _chainSize)
return new SplineChainResumeInfo(_id, _chain, _walk, _nextIndex, 0, 1u);
else
return new SplineChainResumeInfo();
}
return new SplineChainResumeInfo(_id, _chain, _walk, (byte)(_nextIndex - 1), (byte)(me.moveSpline._currentSplineIdx()), _msToNext);
return new SplineChainResumeInfo(_id, _chain, _walk, (byte)(_nextIndex - 1), (byte)(me.MoveSpline._currentSplineIdx()), _msToNext);
}
public override void Reset(Unit owner) { }
@@ -66,7 +66,7 @@ namespace Game.Movement
// prevent movement while casting spells with cast time or channel time
if (owner.IsMovementPreventedByCasting())
{
if (!owner.isStopped())
if (!owner.IsStopped())
owner.StopMoving();
return true;
}
@@ -91,8 +91,8 @@ namespace Game.Movement
else
allowed_dist = owner.GetCombatReach() + WorldConfig.GetFloatValue(WorldCfg.RateTargetPosRecalculationRange);
Vector3 dest = owner.moveSpline.FinalDestination();
if (owner.moveSpline.onTransport)
Vector3 dest = owner.MoveSpline.FinalDestination();
if (owner.MoveSpline.onTransport)
{
float o = 0;
ITransport transport = owner.GetDirectTransport();
@@ -115,7 +115,7 @@ namespace Game.Movement
if (recalculateTravel || targetMoved)
_setTargetLocation(owner, targetMoved);
if (owner.moveSpline.Finalized())
if (owner.MoveSpline.Finalized())
{
MovementInform(owner);
if (angle == 0.0f && !owner.HasInArc(0.01f, target))
@@ -147,7 +147,7 @@ namespace Game.Movement
if (owner.IsMovementPreventedByCasting())
return;
if (owner.IsTypeId(TypeId.Unit) && !target.isInAccessiblePlaceFor(owner.ToCreature()))
if (owner.IsTypeId(TypeId.Unit) && !target.IsInAccessiblePlaceFor(owner.ToCreature()))
{
owner.ToCreature().SetCannotReachTarget(true);
return;
@@ -84,7 +84,7 @@ namespace Game.Movement
if (creature.IsStopped())
Stop(WorldConfig.GetIntValue(WorldCfg.CreatureStopForPlayer));
else if (creature.moveSpline.Finalized())
else if (creature.MoveSpline.Finalized())
{
OnArrived(creature);
return StartMove(creature);
@@ -226,7 +226,7 @@ namespace Game.Movement
init.Launch();
//Call for creature group update
if (creature.GetFormation() != null && creature.GetFormation().getLeader() == creature)
if (creature.GetFormation() != null && creature.GetFormation().GetLeader() == creature)
{
creature.SetWalk(node.moveType != WaypointMoveType.Run);
creature.GetFormation().LeaderMoveTo(formationDest.posX, formationDest.posY, formationDest.posZ);
@@ -358,9 +358,9 @@ namespace Game.Movement
owner.Dismount();
owner.RemoveUnitFlag(UnitFlags.RemoveClientControl | UnitFlags.TaxiFlight);
if (owner.m_taxi.empty())
if (owner.m_taxi.Empty())
{
owner.getHostileRefManager().setOnlineOfflineState(true);
owner.GetHostileRefManager().setOnlineOfflineState(true);
// update z position to ground and orientation for landing point
// this prevent cheating with landing point at lags
// when client side flight end early in comparison server side
@@ -374,7 +374,7 @@ namespace Game.Movement
public override void DoReset(Player owner)
{
owner.getHostileRefManager().setOnlineOfflineState(false);
owner.GetHostileRefManager().setOnlineOfflineState(false);
owner.AddUnitState(UnitState.InFlight);
owner.AddUnitFlag(UnitFlags.RemoveClientControl | UnitFlags.TaxiFlight);
@@ -397,7 +397,7 @@ namespace Game.Movement
public override bool DoUpdate(Player player, uint time_diff)
{
uint pointId = (uint)player.moveSpline.currentPathIdx();
uint pointId = (uint)player.MoveSpline.currentPathIdx();
if (pointId > i_currentNode)
{
bool departureEvent = true;