From f0a5fb6d8051172e5157fde7d96bc42156962506 Mon Sep 17 00:00:00 2001 From: Rich Dunne Date: Wed, 7 Oct 2020 05:00:29 -0600 Subject: [PATCH] Fixed vehicle and driver persistence not being set after dismissal/before recollection --- SceneManager/Menus/PathMainMenu.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/SceneManager/Menus/PathMainMenu.cs b/SceneManager/Menus/PathMainMenu.cs index 2097e75..b4f78e4 100644 --- a/SceneManager/Menus/PathMainMenu.cs +++ b/SceneManager/Menus/PathMainMenu.cs @@ -240,7 +240,7 @@ namespace SceneManager if (selectedItem == directDriver) { - var nearbyVehicle = Game.LocalPlayer.Character.GetNearbyVehicles(1).Where(v => v != Game.LocalPlayer.Character.CurrentVehicle && v.VehicleAndDriverValid()).SingleOrDefault(); + var nearbyVehicle = Game.LocalPlayer.Character.GetNearbyVehicles(3).Where(v => v != Game.LocalPlayer.Character.CurrentVehicle && v.VehicleAndDriverValid()).FirstOrDefault(); if (nearbyVehicle) { @@ -250,16 +250,15 @@ namespace SceneManager var firstWaypoint = waypoints.First(); var nearestWaypoint = waypoints.Where(wp => wp.Position.DistanceTo2D(nearbyVehicle.FrontPosition) < wp.Position.DistanceTo2D(nearbyVehicle.RearPosition)).OrderBy(wp => wp.Position.DistanceTo2D(nearbyVehicle)).FirstOrDefault(); - VehicleCollector.SetVehicleAndDriverPersistence(nearbyVehicle); - if(collectedVehicle != null) { collectedVehicle.Dismiss(); collectedVehicle = null; } + VehicleCollector.SetVehicleAndDriverPersistence(nearbyVehicle); // The vehicle should only be added to the collection when it's not null AND if the selected item is First Waypoint OR if the selected item is nearestWaypoint AND nearestWaypoint is not null - if (collectedVehicle == null && (directOptions.SelectedItem == "First waypoint" || (directOptions.SelectedItem == "Nearest waypoint" && nearestWaypoint != null))) + if (collectedVehicle == null && directOptions.SelectedItem == "First waypoint" || (directOptions.SelectedItem == "Nearest waypoint" && nearestWaypoint != null)) { Game.LogTrivial($"[Direct Driver] {nearbyVehicle.Model.Name} not found in collection, adding now."); VehicleCollector.collectedVehicles.Add(new CollectedVehicle(nearbyVehicle, path));