mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 15:40:29 +01:00
Removed GetPaths() method from PathMainMenu and updated references to paths list.
This commit is contained in:
parent
3c636c1564
commit
2241e107de
6 changed files with 42 additions and 41 deletions
|
|
@ -32,7 +32,7 @@ namespace SceneManager
|
|||
|
||||
private static void EditPath_OnItemSelected(UIMenu sender, UIMenuItem selectedItem, int index)
|
||||
{
|
||||
var currentPath = PathMainMenu.GetPaths()[PathMainMenu.editPath.Index];
|
||||
var currentPath = PathMainMenu.paths[PathMainMenu.editPath.Index];
|
||||
|
||||
if (selectedItem == editPathWaypoints)
|
||||
{
|
||||
|
|
@ -49,7 +49,7 @@ namespace SceneManager
|
|||
{
|
||||
if (checkboxItem == disablePath)
|
||||
{
|
||||
var currentPath = PathMainMenu.GetPaths()[PathMainMenu.editPath.Index];
|
||||
var currentPath = PathMainMenu.paths[PathMainMenu.editPath.Index];
|
||||
if (disablePath.Checked)
|
||||
{
|
||||
currentPath.DisablePath();
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace SceneManager
|
|||
// Need to unsubscribe from these or else there will be duplicate firings if the user left the menu, then re-entered
|
||||
ResetEventHandlerSubscriptions();
|
||||
|
||||
var currentPath = PathMainMenu.GetPaths()[PathMainMenu.editPath.Value - 1];
|
||||
var currentPath = PathMainMenu.paths[PathMainMenu.editPath.Value-1];
|
||||
//Logger.Log($"Current path: {currentPath.Number}");
|
||||
|
||||
editWaypoint = new UIMenuNumericScrollerItem<int>("Edit Waypoint", "", currentPath.Waypoints.First().Number, currentPath.Waypoints.Last().Number, 1);
|
||||
|
|
@ -95,7 +95,7 @@ namespace SceneManager
|
|||
|
||||
private static void EditWaypoint_OnScrollerChanged(UIMenu sender, UIMenuScrollerItem scrollerItem, int first, int last)
|
||||
{
|
||||
var currentPath = PathMainMenu.GetPaths()[PathMainMenu.editPath.Value - 1];
|
||||
var currentPath = PathMainMenu.paths[PathMainMenu.editPath.Index];
|
||||
var currentWaypoint = currentPath.Waypoints[editWaypoint.Value - 1];
|
||||
|
||||
if (scrollerItem == editWaypoint)
|
||||
|
|
@ -136,7 +136,7 @@ namespace SceneManager
|
|||
|
||||
private static void EditWaypoint_OnItemSelected(UIMenu sender, UIMenuItem selectedItem, int index)
|
||||
{
|
||||
var currentPath = PathMainMenu.GetPaths()[PathMainMenu.editPath.Index];
|
||||
var currentPath = PathMainMenu.paths[PathMainMenu.editPath.Index];
|
||||
var currentWaypoint = currentPath.Waypoints[editWaypoint.Index];
|
||||
|
||||
if (selectedItem == updateWaypoint)
|
||||
|
|
@ -160,7 +160,7 @@ namespace SceneManager
|
|||
|
||||
if (selectedItem == addAsNewWaypoint)
|
||||
{
|
||||
var pathIndex = PathMainMenu.GetPaths().IndexOf(currentPath);
|
||||
var pathIndex = PathMainMenu.paths.IndexOf(currentPath);
|
||||
var drivingFlag = drivingFlags[changeWaypointType.Index];
|
||||
var blip = PathCreationMenu.CreateWaypointBlip(pathIndex, drivingFlag);
|
||||
if (!currentPath.IsEnabled)
|
||||
|
|
|
|||
|
|
@ -76,29 +76,29 @@ namespace SceneManager
|
|||
{
|
||||
if (selectedItem == trafficAddWaypoint)
|
||||
{
|
||||
var anyPathsExist = PathMainMenu.GetPaths().Count > 0;
|
||||
var anyPathsExist = PathMainMenu.paths.Count > 0;
|
||||
|
||||
if (!anyPathsExist)
|
||||
{
|
||||
AddNewPathToPathsCollection(PathMainMenu.GetPaths(), 0);
|
||||
AddNewPathToPathsCollection(PathMainMenu.paths, 0);
|
||||
}
|
||||
else if(anyPathsExist && !PathMainMenu.GetPaths().Any(p => p != null && p.State == State.Creating))
|
||||
else if(anyPathsExist && !PathMainMenu.paths.Any(p => p != null && p.State == State.Creating))
|
||||
{
|
||||
AddNewPathToPathsCollection(PathMainMenu.GetPaths(), PathMainMenu.GetPaths().IndexOf(PathMainMenu.GetPaths().Where(p => p.State == State.Finished).First()) + 1);
|
||||
AddNewPathToPathsCollection(PathMainMenu.paths, PathMainMenu.paths.IndexOf(PathMainMenu.paths.Where(p => p.State == State.Finished).First()) + 1);
|
||||
}
|
||||
|
||||
var firstNonNullPath = PathMainMenu.GetPaths().Where(p => p != null && p.State == State.Creating).First();
|
||||
var pathIndex = PathMainMenu.GetPaths().IndexOf(firstNonNullPath);
|
||||
var firstNonNullPath = PathMainMenu.paths.Where(p => p != null && p.State == State.Creating).First();
|
||||
var pathIndex = PathMainMenu.paths.IndexOf(firstNonNullPath);
|
||||
var pathNumber = firstNonNullPath.Number;
|
||||
var waypointNumber = PathMainMenu.GetPaths()[pathIndex].Waypoints.Count + 1;
|
||||
var waypointNumber = PathMainMenu.paths[pathIndex].Waypoints.Count + 1;
|
||||
|
||||
if (collectorWaypoint.Checked)
|
||||
{
|
||||
PathMainMenu.GetPaths()[pathIndex].Waypoints.Add(new Waypoint(firstNonNullPath, waypointNumber, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlags[waypointType.Index], CreateWaypointBlip(pathIndex, drivingFlags[waypointType.Index]), true, collectorRadius.Value, speedZoneRadius.Value));
|
||||
PathMainMenu.paths[pathIndex].Waypoints.Add(new Waypoint(firstNonNullPath, waypointNumber, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlags[waypointType.Index], CreateWaypointBlip(pathIndex, drivingFlags[waypointType.Index]), true, collectorRadius.Value, speedZoneRadius.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
PathMainMenu.GetPaths()[pathIndex].Waypoints.Add(new Waypoint(firstNonNullPath, waypointNumber, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlags[waypointType.Index], CreateWaypointBlip(pathIndex, drivingFlags[waypointType.Index])));
|
||||
PathMainMenu.paths[pathIndex].Waypoints.Add(new Waypoint(firstNonNullPath, waypointNumber, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlags[waypointType.Index], CreateWaypointBlip(pathIndex, drivingFlags[waypointType.Index])));
|
||||
}
|
||||
Logger.Log($"[Path {pathNumber}] Waypoint {waypointNumber} ({drivingFlags[waypointType.Index].ToString()}) added");
|
||||
|
||||
|
|
@ -130,24 +130,24 @@ namespace SceneManager
|
|||
if (selectedItem == trafficRemoveWaypoint)
|
||||
{
|
||||
// Loop through each path and find the first one which isn't finished, then delete the path's last waypoint and corresponding blip
|
||||
for (int i = 0; i < PathMainMenu.GetPaths().Count; i++)
|
||||
for (int i = 0; i < PathMainMenu.paths.Count; i++)
|
||||
{
|
||||
if (PathMainMenu.GetPaths().ElementAtOrDefault(i) != null && PathMainMenu.GetPaths()[i].State == State.Creating)
|
||||
if (PathMainMenu.paths.ElementAtOrDefault(i) != null && PathMainMenu.paths[i].State == State.Creating)
|
||||
{
|
||||
Logger.Log($"[Path {i + 1}] {PathMainMenu.GetPaths()[i].Waypoints.Last().DrivingFlag.ToString()} waypoint removed");
|
||||
PathMainMenu.GetPaths()[i].Waypoints.Last().Blip.Delete();
|
||||
PathMainMenu.GetPaths()[i].Waypoints.Last().RemoveSpeedZone();
|
||||
Logger.Log($"[Path {i + 1}] {PathMainMenu.paths[i].Waypoints.Last().DrivingFlag.ToString()} waypoint removed");
|
||||
PathMainMenu.paths[i].Waypoints.Last().Blip.Delete();
|
||||
PathMainMenu.paths[i].Waypoints.Last().RemoveSpeedZone();
|
||||
|
||||
if (PathMainMenu.GetPaths()[i].Waypoints.Last().CollectorRadiusBlip)
|
||||
if (PathMainMenu.paths[i].Waypoints.Last().CollectorRadiusBlip)
|
||||
{
|
||||
PathMainMenu.GetPaths()[i].Waypoints.Last().CollectorRadiusBlip.Delete();
|
||||
PathMainMenu.paths[i].Waypoints.Last().CollectorRadiusBlip.Delete();
|
||||
}
|
||||
PathMainMenu.GetPaths()[i].Waypoints.RemoveAt(PathMainMenu.GetPaths()[i].Waypoints.IndexOf(PathMainMenu.GetPaths()[i].Waypoints.Last()));
|
||||
PathMainMenu.paths[i].Waypoints.RemoveAt(PathMainMenu.paths[i].Waypoints.IndexOf(PathMainMenu.paths[i].Waypoints.Last()));
|
||||
|
||||
ToggleTrafficEndPathMenuItem(i);
|
||||
|
||||
// If the path has no waypoints, disable the menu option to remove a waypoint
|
||||
if (PathMainMenu.GetPaths()[i].Waypoints.Count == 0)
|
||||
if (PathMainMenu.paths[i].Waypoints.Count == 0)
|
||||
{
|
||||
collectorWaypoint.Checked = true;
|
||||
collectorWaypoint.Enabled = false;
|
||||
|
|
@ -163,10 +163,10 @@ namespace SceneManager
|
|||
if (selectedItem == trafficEndPath)
|
||||
{
|
||||
// Loop through each path and find the first one which isn't finished
|
||||
for (int i = 0; i < PathMainMenu.GetPaths().Count; i++)
|
||||
for (int i = 0; i < PathMainMenu.paths.Count; i++)
|
||||
{
|
||||
var currentPath = PathMainMenu.GetPaths()[i];
|
||||
if (PathMainMenu.GetPaths().ElementAtOrDefault(i) != null && currentPath.State == State.Creating)
|
||||
var currentPath = PathMainMenu.paths[i];
|
||||
if (PathMainMenu.paths.ElementAtOrDefault(i) != null && currentPath.State == State.Creating)
|
||||
{
|
||||
Logger.Log($"[Path Creation] Path {currentPath.Number} finished with {currentPath.Waypoints.Count} waypoints.");
|
||||
Game.DisplayNotification($"~o~Scene Manager\n~g~[Success]~w~ Path {i + 1} complete.");
|
||||
|
|
@ -174,14 +174,16 @@ namespace SceneManager
|
|||
currentPath.IsEnabled = true;
|
||||
currentPath.Number = i + 1;
|
||||
|
||||
foreach (Waypoint waypoint in PathMainMenu.GetPaths()[i].Waypoints)
|
||||
foreach (Waypoint waypoint in PathMainMenu.paths[i].Waypoints)
|
||||
{
|
||||
GameFiber WaypointVehicleCollectorFiber = new GameFiber(() => VehicleCollector.StartCollectingAtWaypoint(PathMainMenu.GetPaths(), PathMainMenu.GetPaths()[i], waypoint));
|
||||
GameFiber WaypointVehicleCollectorFiber = new GameFiber(() => VehicleCollector.StartCollectingAtWaypoint(PathMainMenu.paths, PathMainMenu.paths[i], waypoint));
|
||||
WaypointVehicleCollectorFiber.Start();
|
||||
}
|
||||
|
||||
PathMainMenu.createNewPath.Text = "Create New Path";
|
||||
PathMainMenu.BuildPathMenu();
|
||||
PathMainMenu.pathMainMenu.RefreshIndex();
|
||||
pathCreationMenu.RefreshIndex();
|
||||
collectorWaypoint.Enabled = false;
|
||||
collectorWaypoint.Checked = true;
|
||||
speedZoneRadius.Enabled = true;
|
||||
|
|
@ -216,7 +218,7 @@ namespace SceneManager
|
|||
|
||||
private static void ToggleTrafficEndPathMenuItem(int pathIndex)
|
||||
{
|
||||
if (PathMainMenu.GetPaths()[pathIndex].Waypoints.Count > 0)
|
||||
if (PathMainMenu.paths[pathIndex].Waypoints.Count > 0)
|
||||
{
|
||||
trafficEndPath.Enabled = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace SceneManager
|
|||
{
|
||||
static class PathMainMenu
|
||||
{
|
||||
private static List<Path> paths = new List<Path>() { };
|
||||
internal static List<Path> paths = new List<Path>() { };
|
||||
private static List<string> dismissOptions = new List<string>() { "From path", "From waypoint", "From position" };
|
||||
|
||||
internal static UIMenu pathMainMenu = new UIMenu("Scene Manager", "~o~Path Manager Main Menu");
|
||||
|
|
@ -81,11 +81,6 @@ namespace SceneManager
|
|||
}
|
||||
}
|
||||
|
||||
internal static ref List<Path> GetPaths()
|
||||
{
|
||||
return ref paths;
|
||||
}
|
||||
|
||||
private static bool VehicleAndDriverValid(this Vehicle v)
|
||||
{
|
||||
if (v && v.HasDriver && v.Driver && v.Driver.IsAlive)
|
||||
|
|
@ -233,6 +228,10 @@ namespace SceneManager
|
|||
}
|
||||
|
||||
collectedVehicle.Driver.Tasks.Clear();
|
||||
if (collectedVehicle.StoppedAtWaypoint)
|
||||
{
|
||||
collectedVehicle.StoppedAtWaypoint = false;
|
||||
}
|
||||
|
||||
if (directOptions.SelectedItem == "First waypoint")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ namespace SceneManager
|
|||
{
|
||||
if (mapBlips.Checked)
|
||||
{
|
||||
foreach(Path path in PathMainMenu.GetPaths())
|
||||
foreach(Path path in PathMainMenu.paths)
|
||||
{
|
||||
foreach(Waypoint wp in path.Waypoints)
|
||||
{
|
||||
|
|
@ -61,7 +61,7 @@ namespace SceneManager
|
|||
}
|
||||
else
|
||||
{
|
||||
foreach (Path path in PathMainMenu.GetPaths())
|
||||
foreach (Path path in PathMainMenu.paths)
|
||||
{
|
||||
foreach (Waypoint wp in path.Waypoints)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue