From 29221024095e33e073b53a2f699709f190705a5f Mon Sep 17 00:00:00 2001 From: Rich Dunne Date: Tue, 22 Sep 2020 14:49:54 -0600 Subject: [PATCH] Added function to loop while the path exists checking for vehicles which need to be dismissed for cleanup --- SceneManager/VehicleCollector.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/SceneManager/VehicleCollector.cs b/SceneManager/VehicleCollector.cs index 0c1dc70..ed1b2a7 100644 --- a/SceneManager/VehicleCollector.cs +++ b/SceneManager/VehicleCollector.cs @@ -15,6 +15,8 @@ namespace SceneManager internal static void StartCollectingAtWaypoint(List paths, Path path, Waypoint waypoint) { + LoopForVehiclesToBeDismissed(paths, path); + while (paths.Contains(path) && path.Waypoints.Contains(waypoint)) { if (path.IsEnabled && waypoint.IsCollector) @@ -25,6 +27,29 @@ namespace SceneManager } } + private static void LoopForVehiclesToBeDismissed(List paths, Path path) + { + GameFiber.StartNew(() => + { + while (paths.Contains(path)) + { + Logger.Log($"Cleaning up bad collected vehicles"); + foreach (CollectedVehicle cv in collectedVehicles) + { + if (!cv.Vehicle.IsDriveable || cv.Vehicle.IsUpsideDown || !cv.Vehicle.HasDriver) + { + if (cv.Vehicle.HasDriver) + { + cv.Vehicle.Driver.Dismiss(); + } + cv.Vehicle.Dismiss(); + } + } + GameFiber.Sleep(10000); + } + }); + } + private static void LoopForNearbyValidVehicles(Path path, Waypoint waypoint) { foreach (Vehicle vehicle in GetNearbyVehiclesForCollection(waypoint.Position, waypoint.CollectorRadius))