1
Fork 0
mirror of https://github.com/thegeneralist01/Scene-Manager-DevRepo synced 2026-01-11 23:50:29 +01:00

Renamed VehicleAndDriverNullChecks to VehicleAndDriverAreValid for better readability.

This commit is contained in:
Rich Dunne 2020-09-24 04:13:35 -06:00
parent da1dd590f7
commit eba20888e0

View file

@ -8,7 +8,7 @@ namespace SceneManager
{ {
internal static void AssignWaypointTasks(CollectedVehicle collectedVehicle, List<Waypoint> waypoints, Waypoint currentWaypoint) internal static void AssignWaypointTasks(CollectedVehicle collectedVehicle, List<Waypoint> waypoints, Waypoint currentWaypoint)
{ {
if (!VehicleAndDriverNullChecks(collectedVehicle)) if (!VehicleAndDriverAreValid(collectedVehicle))
{ {
return; return;
} }
@ -29,7 +29,7 @@ namespace SceneManager
} }
DriveVehicleToNextWaypoint(collectedVehicle, waypoints, currentWaypoint); DriveVehicleToNextWaypoint(collectedVehicle, waypoints, currentWaypoint);
if (!VehicleAndDriverNullChecks(collectedVehicle)) if (!VehicleAndDriverAreValid(collectedVehicle))
{ {
return; return;
} }
@ -42,7 +42,7 @@ namespace SceneManager
void LoopWhileDrivingToWaypoint(float acceptedDistance) void LoopWhileDrivingToWaypoint(float acceptedDistance)
{ {
while (VehicleAndDriverNullChecks(collectedVehicle) && !collectedVehicle.Dismissed && !collectedVehicle.SkipWaypoint && collectedVehicle.Vehicle.FrontPosition.DistanceTo2D(currentWaypoint.Position) > acceptedDistance) while (VehicleAndDriverAreValid(collectedVehicle) && !collectedVehicle.Dismissed && !collectedVehicle.SkipWaypoint && collectedVehicle.Vehicle.FrontPosition.DistanceTo2D(currentWaypoint.Position) > acceptedDistance)
{ {
//Logger.Log($"Looping while {collectedVehicle.Vehicle.Model.Name} drives to waypoint {currentWaypoint.Number} ({collectedVehicle.Vehicle.DistanceTo2D(currentWaypoint.Position)}m away)"); //Logger.Log($"Looping while {collectedVehicle.Vehicle.Model.Name} drives to waypoint {currentWaypoint.Number} ({collectedVehicle.Vehicle.DistanceTo2D(currentWaypoint.Position)}m away)");
GameFiber.Yield(); GameFiber.Yield();
@ -52,7 +52,7 @@ namespace SceneManager
private static void DriveVehicleToNextWaypoint(CollectedVehicle collectedVehicle, List<Waypoint> waypoints, Waypoint currentWaypoint) private static void DriveVehicleToNextWaypoint(CollectedVehicle collectedVehicle, List<Waypoint> waypoints, Waypoint currentWaypoint)
{ {
if (!VehicleAndDriverNullChecks(collectedVehicle) || currentWaypoint == null || currentWaypoint.Path == null) if (!VehicleAndDriverAreValid(collectedVehicle) || currentWaypoint == null || currentWaypoint.Path == null)
{ {
return; return;
} }
@ -62,7 +62,7 @@ namespace SceneManager
for (int nextWaypoint = currentWaypoint.Number; nextWaypoint < waypoints.Count; nextWaypoint++) for (int nextWaypoint = currentWaypoint.Number; nextWaypoint < waypoints.Count; nextWaypoint++)
{ {
if (!VehicleAndDriverNullChecks(waypoints, nextWaypoint, collectedVehicle) || collectedVehicle.Dismissed) if (!VehicleAndDriverAreValid(waypoints, nextWaypoint, collectedVehicle) || collectedVehicle.Dismissed)
{ {
return; return;
} }
@ -88,7 +88,7 @@ namespace SceneManager
} }
LoopWhileDrivingToWaypoint(nextWaypoint, acceptedDistance); LoopWhileDrivingToWaypoint(nextWaypoint, acceptedDistance);
if (!VehicleAndDriverNullChecks(collectedVehicle)) if (!VehicleAndDriverAreValid(collectedVehicle))
{ {
return; return;
} }
@ -104,7 +104,7 @@ namespace SceneManager
StopVehicleAtWaypoint(waypoints[nextWaypoint], collectedVehicle); StopVehicleAtWaypoint(waypoints[nextWaypoint], collectedVehicle);
} }
if (!VehicleAndDriverNullChecks(collectedVehicle) || collectedVehicle.Dismissed) if (!VehicleAndDriverAreValid(collectedVehicle) || collectedVehicle.Dismissed)
{ {
return; return;
} }
@ -118,7 +118,7 @@ namespace SceneManager
void LoopWhileDrivingToWaypoint(int nextWaypoint, float acceptedDistance) void LoopWhileDrivingToWaypoint(int nextWaypoint, float acceptedDistance)
{ {
while (VehicleAndDriverNullChecks(collectedVehicle) && !collectedVehicle.Dismissed && !collectedVehicle.SkipWaypoint && waypoints.ElementAtOrDefault(nextWaypoint) != null && vehicle.FrontPosition.DistanceTo2D(waypoints[nextWaypoint].Position) > acceptedDistance) while (VehicleAndDriverAreValid(collectedVehicle) && !collectedVehicle.Dismissed && !collectedVehicle.SkipWaypoint && waypoints.ElementAtOrDefault(nextWaypoint) != null && collectedVehicle.Vehicle.FrontPosition.DistanceTo2D(waypoints[nextWaypoint].Position) > acceptedDistance)
{ {
//Logger.Log($"Dismissed: {collectedVehicle.Dismissed} SkipWaypoint: {collectedVehicle.SkipWaypoint}"); //Logger.Log($"Dismissed: {collectedVehicle.Dismissed} SkipWaypoint: {collectedVehicle.SkipWaypoint}");
if (waypoints[nextWaypoint].DrivingFlag == VehicleDrivingFlags.IgnorePathFinding) if (waypoints[nextWaypoint].DrivingFlag == VehicleDrivingFlags.IgnorePathFinding)
@ -152,7 +152,7 @@ namespace SceneManager
return acceptedDistance; return acceptedDistance;
} }
private static bool VehicleAndDriverNullChecks(CollectedVehicle collectedVehicle) private static bool VehicleAndDriverAreValid(CollectedVehicle collectedVehicle)
{ {
if (collectedVehicle == null) if (collectedVehicle == null)
{ {
@ -172,7 +172,7 @@ namespace SceneManager
return true; return true;
} }
private static bool VehicleAndDriverNullChecks(List<Waypoint> waypoints, int nextWaypoint, CollectedVehicle collectedVehicle) private static bool VehicleAndDriverAreValid(List<Waypoint> waypoints, int nextWaypoint, CollectedVehicle collectedVehicle)
{ {
if (waypoints.ElementAtOrDefault(nextWaypoint) == null) if (waypoints.ElementAtOrDefault(nextWaypoint) == null)
{ {
@ -199,7 +199,7 @@ namespace SceneManager
private static void StopVehicleAtWaypoint(Waypoint currentWaypoint, CollectedVehicle collectedVehicle) private static void StopVehicleAtWaypoint(Waypoint currentWaypoint, CollectedVehicle collectedVehicle)
{ {
if (!VehicleAndDriverNullChecks(collectedVehicle)) if (!VehicleAndDriverAreValid(collectedVehicle))
{ {
return; return;
} }
@ -209,7 +209,7 @@ namespace SceneManager
Rage.Native.NativeFunction.Natives.x260BE8F09E326A20(collectedVehicle.Vehicle, stoppingDistance, -1, true); Rage.Native.NativeFunction.Natives.x260BE8F09E326A20(collectedVehicle.Vehicle, stoppingDistance, -1, true);
collectedVehicle.StoppedAtWaypoint = true; collectedVehicle.StoppedAtWaypoint = true;
while (currentWaypoint != null && VehicleAndDriverNullChecks(collectedVehicle) && collectedVehicle.StoppedAtWaypoint) while (currentWaypoint != null && VehicleAndDriverAreValid(collectedVehicle) && collectedVehicle.StoppedAtWaypoint)
{ {
GameFiber.Yield(); GameFiber.Yield();
} }