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))