Core: SOme code cleanup, more to follow.

This commit is contained in:
hondacrx
2021-03-20 22:48:48 -04:00
parent 62f554f2e0
commit 62ec699ec6
318 changed files with 5080 additions and 5125 deletions
@@ -83,7 +83,7 @@ namespace Game.Movement
return true;
}
MoveSplineInit init = new MoveSplineInit(owner);
MoveSplineInit init = new(owner);
init.MovebyPath(_path.GetPath());
init.SetWalk(true);
int traveltime = init.Launch();
@@ -122,7 +122,7 @@ namespace Game.Movement
return;
}
MoveSplineInit init = new MoveSplineInit(owner);
MoveSplineInit init = new(owner);
init.MovebyPath(_path.GetPath());
init.SetWalk(false);
int traveltime = init.Launch();
@@ -126,12 +126,12 @@ namespace Game.Movement
owner.AddUnitState(UnitState.InFlight);
owner.AddUnitFlag(UnitFlags.RemoveClientControl | UnitFlags.TaxiFlight);
MoveSplineInit init = new MoveSplineInit(owner);
MoveSplineInit init = new(owner);
uint end = GetPathAtMapEnd();
init.args.path = new Vector3[end];
for (int i = (int)GetCurrentNode(); i != end; ++i)
{
Vector3 vertice = new Vector3(_path[i].Loc.X, _path[i].Loc.Y, _path[i].Loc.Z);
Vector3 vertice = new(_path[i].Loc.X, _path[i].Loc.Y, _path[i].Loc.Z);
init.args.path[i] = vertice;
}
init.SetFirstPointId((int)GetCurrentNode());
@@ -252,9 +252,9 @@ namespace Game.Movement
uint _endMapId; //! map Id of last node location
uint _preloadTargetNode; //! node index where preloading starts
List<TaxiPathNodeRecord> _path = new List<TaxiPathNodeRecord>();
List<TaxiPathNodeRecord> _path = new();
int _currentNode;
List<TaxiNodeChangeInfo> _pointsForPathSwitch = new List<TaxiNodeChangeInfo>(); //! node indexes and costs where TaxiPath changes
List<TaxiNodeChangeInfo> _pointsForPathSwitch = new(); //! node indexes and costs where TaxiPath changes
class TaxiNodeChangeInfo
{
@@ -44,7 +44,7 @@ namespace Game.Movement
owner.AddUnitState(UnitState.RoamingMove);
MoveSplineInit init = new MoveSplineInit(owner);
MoveSplineInit init = new(owner);
init.MoveTo(_destination.GetPositionX(), _destination.GetPositionY(), _destination.GetPositionZ());
if (_orientation)
init.SetFacing(_destination.GetOrientation());
@@ -96,7 +96,7 @@ namespace Game.Movement
owner.AddUnitState(UnitState.RoamingMove);
MoveSplineInit init = new MoveSplineInit(owner);
MoveSplineInit init = new(owner);
init.MoveTo(_destination.GetPositionX(), _destination.GetPositionY(), _destination.GetPositionZ());
if (_orientation)
init.SetFacing(_destination.GetOrientation());
@@ -59,7 +59,7 @@ namespace Game.AI
return;
}
MoveSplineInit init = new MoveSplineInit(owner);
MoveSplineInit init = new(owner);
float x, y, z, o;
// at apply we can select more nice return points base at current movegen
if (owner.GetMotionMaster().Empty() || !owner.GetMotionMaster().Top().GetResetPosition(owner, out x, out y, out z))
@@ -55,10 +55,10 @@ namespace Game.Movement
if (!GridDefines.IsValidMapCoord(destX, destY, destZ) || !GridDefines.IsValidMapCoord(x, y, z))
return false;
Vector3 dest = new Vector3(destX, destY, destZ);
Vector3 dest = new(destX, destY, destZ);
SetEndPosition(dest);
Vector3 start = new Vector3(x, y, z);
Vector3 start = new(x, y, z);
SetStartPosition(start);
_forceDestination = forceDest;
@@ -477,8 +477,8 @@ namespace Game.Movement
Array.Copy(startPoint, pathPoints, 3); // first point
// path has to be split into polygons with dist SMOOTH_PATH_STEP_SIZE between them
Vector3 startVec = new Vector3(startPoint[0], startPoint[1], startPoint[2]);
Vector3 endVec = new Vector3(endPoint[0], endPoint[1], endPoint[2]);
Vector3 startVec = new(startPoint[0], startPoint[1], startPoint[2]);
Vector3 endVec = new(endPoint[0], endPoint[1], endPoint[2]);
Vector3 diffVec = (endVec - startVec);
Vector3 prevVec = startVec;
float len = diffVec.GetLength();
@@ -976,7 +976,7 @@ namespace Game.Movement
Vector3 _endPosition;
PathType pathType;
Detour.dtQueryFilter _filter = new Detour.dtQueryFilter();
Detour.dtQueryFilter _filter = new();
Detour.dtNavMeshQuery _navMeshQuery;
Detour.dtNavMesh _navMesh;
}
@@ -52,7 +52,7 @@ namespace Game.Movement
owner.AddUnitState(UnitState.RoamingMove);
MoveSplineInit init = new MoveSplineInit(owner);
MoveSplineInit init = new(owner);
init.MoveTo(_destination.GetPositionX(), _destination.GetPositionY(), _destination.GetPositionZ(), _generatePath);
if (_speed > 0.0f)
init.SetVelocity(_speed);
@@ -99,7 +99,7 @@ namespace Game.Movement
owner.AddUnitState(UnitState.RoamingMove);
MoveSplineInit init = new MoveSplineInit(owner);
MoveSplineInit init = new(owner);
init.MoveTo(_destination.GetPositionX(), _destination.GetPositionY(), _destination.GetPositionZ(), _generatePath);
if (_speed > 0.0f) // Default value for point motion type is 0.0, if 0.0 spline will use GetSpeed on unit
init.SetVelocity(_speed);
@@ -92,7 +92,7 @@ namespace Game.Movement
owner.AddUnitState(UnitState.RoamingMove);
Position position = new Position(_reference);
Position position = new(_reference);
float distance = RandomHelper.FRand(0.0f, 1.0f) * _wanderDistance;
float angle = RandomHelper.FRand(0.0f, 1.0f) * MathF.PI * 2.0f;
owner.MovePositionToFirstCollision(ref position, distance, angle);
@@ -110,7 +110,7 @@ namespace Game.Movement
return;
}
MoveSplineInit init = new MoveSplineInit(owner);
MoveSplineInit init = new(owner);
init.MovebyPath(_path.GetPath());
init.SetWalk(true);
int traveltime = init.Launch();
@@ -48,7 +48,7 @@ namespace Game.Movement
{
int numWp = wp.Length;
Cypher.Assert(numWp > 1, "Every path must have source & destination");
MoveSplineInit init = new MoveSplineInit(me);
MoveSplineInit init = new(me);
if (numWp > 2)
init.MovebyPath(wp.ToArray());
else
@@ -174,7 +174,7 @@ namespace Game.Movement
public override MovementGeneratorType GetMovementGeneratorType() { return MovementGeneratorType.SplineChain; }
uint _id;
List<SplineChainLink> _chain = new List<SplineChainLink>();
List<SplineChainLink> _chain = new();
byte _chainSize;
bool _walk;
bool finished;
@@ -201,7 +201,7 @@ namespace Game.Movement
if (owner.IsTypeId(TypeId.Unit))
owner.ToCreature().SetCannotReachTarget(false);
MoveSplineInit init = new MoveSplineInit(owner);
MoveSplineInit init = new(owner);
init.MovebyPath(_path.GetPath());
init.SetWalk(EnableWalking());
// Using the same condition for facing target as the one that is used for SetInFront on movement end
@@ -179,14 +179,14 @@ namespace Game.Movement
Cypher.Assert(_currentNode < _path.nodes.Count, $"WaypointMovementGenerator.StartMove: tried to reference a node id ({_currentNode}) which is not included in path ({_path.id})");
WaypointNode waypoint = _path.nodes.ElementAt(_currentNode);
Position formationDest = new Position(waypoint.x, waypoint.y, waypoint.z, (waypoint.orientation != 0 && waypoint.delay != 0) ? waypoint.orientation : 0.0f);
Position formationDest = new(waypoint.x, waypoint.y, waypoint.z, (waypoint.orientation != 0 && waypoint.delay != 0) ? waypoint.orientation : 0.0f);
_isArrivalDone = false;
_recalculateSpeed = false;
creature.AddUnitState(UnitState.RoamingMove);
MoveSplineInit init = new MoveSplineInit(creature);
MoveSplineInit init = new(creature);
//! If creature is on transport, we assume waypoints set in DB are already transport offsets
if (transportPath)