mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 23:50:29 +01:00
Added guard clauses to return/continue if collected vehicle is dismissed/skipping waypoint. Added check in LoopWhileDrivingToWaypoint to ensure vehicles are driving to the correct position if a waypoint position was updated.
This commit is contained in:
parent
139a1a4163
commit
c7ef4ab52d
1 changed files with 15 additions and 3 deletions
|
|
@ -62,10 +62,14 @@ 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))
|
if (!VehicleAndDriverNullChecks(waypoints, nextWaypoint, collectedVehicle) || collectedVehicle.Dismissed)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (collectedVehicle.SkipWaypoint)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (waypoints.ElementAtOrDefault(nextWaypoint) != null && !collectedVehicle.StoppedAtWaypoint)
|
if (waypoints.ElementAtOrDefault(nextWaypoint) != null && !collectedVehicle.StoppedAtWaypoint)
|
||||||
{
|
{
|
||||||
|
|
@ -114,12 +118,20 @@ namespace SceneManager
|
||||||
|
|
||||||
void LoopWhileDrivingToWaypoint(int nextWaypoint, float acceptedDistance)
|
void LoopWhileDrivingToWaypoint(int nextWaypoint, float acceptedDistance)
|
||||||
{
|
{
|
||||||
//Logger.Log($"Dismissed: {collectedVehicle.Dismissed} SkipWaypoint: {collectedVehicle.SkipWaypoint}");
|
|
||||||
while (VehicleAndDriverNullChecks(collectedVehicle) && !collectedVehicle.Dismissed && !collectedVehicle.SkipWaypoint && waypoints.ElementAtOrDefault(nextWaypoint) != null && vehicle.FrontPosition.DistanceTo2D(waypoints[nextWaypoint].Position) > acceptedDistance)
|
while (VehicleAndDriverNullChecks(collectedVehicle) && !collectedVehicle.Dismissed && !collectedVehicle.SkipWaypoint && waypoints.ElementAtOrDefault(nextWaypoint) != null && vehicle.FrontPosition.DistanceTo2D(waypoints[nextWaypoint].Position) > acceptedDistance)
|
||||||
{
|
{
|
||||||
|
//Logger.Log($"Dismissed: {collectedVehicle.Dismissed} SkipWaypoint: {collectedVehicle.SkipWaypoint}");
|
||||||
|
if (waypoints[nextWaypoint].DrivingFlag == VehicleDrivingFlags.IgnorePathFinding)
|
||||||
|
{
|
||||||
|
driver.Tasks.DriveToPosition(waypoints[nextWaypoint].Position, waypoints[nextWaypoint].Speed, (VehicleDrivingFlags)17040299, acceptedDistance);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
driver.Tasks.DriveToPosition(waypoints[nextWaypoint].Position, waypoints[nextWaypoint].Speed, (VehicleDrivingFlags)263075, acceptedDistance);
|
||||||
|
}
|
||||||
//Logger.Log($"Looping while {collectedVehicle.Vehicle.Model.Name} drives to waypoint {waypoints[nextWaypoint].Number} ({collectedVehicle.Vehicle.DistanceTo2D(waypoints[nextWaypoint].Position)}m away from collector radius {waypoints[nextWaypoint].CollectorRadius})");
|
//Logger.Log($"Looping while {collectedVehicle.Vehicle.Model.Name} drives to waypoint {waypoints[nextWaypoint].Number} ({collectedVehicle.Vehicle.DistanceTo2D(waypoints[nextWaypoint].Position)}m away from collector radius {waypoints[nextWaypoint].CollectorRadius})");
|
||||||
//Logger.Log($"Distance of front of vehicle to waypoint: {collectedVehicle.Vehicle.FrontPosition.DistanceTo2D(waypoints[nextWaypoint].Position)}");
|
//Logger.Log($"Distance of front of vehicle to waypoint: {collectedVehicle.Vehicle.FrontPosition.DistanceTo2D(waypoints[nextWaypoint].Position)}");
|
||||||
GameFiber.Yield();
|
GameFiber.Sleep(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue