1
Fork 0
mirror of https://github.com/thegeneralist01/Scene-Manager-DevRepo synced 2026-01-11 15:40:29 +01:00

Refactored reference names, removed unused code.

This commit is contained in:
Rich Dunne 2020-09-05 14:05:30 -06:00
parent 6b2cb588cb
commit 801eca2cb2
2 changed files with 29 additions and 30 deletions

View file

@ -75,7 +75,7 @@ namespace SceneManager
if (SettingsMenu.debugGraphics.Checked)
{
DebugGraphics.LoopToDrawDebugGraphics(SettingsMenu.debugGraphics, PathMainMenu.GetPaths()[0]);
DebugGraphics.LoopToDrawDebugGraphics(PathMainMenu.GetPaths()[0]);
}
}
else if(anyPathsExist && !PathMainMenu.GetPaths().Any(p => p != null && p.State == State.Creating))
@ -84,13 +84,13 @@ namespace SceneManager
if (SettingsMenu.debugGraphics.Checked)
{
DebugGraphics.LoopToDrawDebugGraphics(SettingsMenu.debugGraphics, PathMainMenu.GetPaths().Where(p => p != null && p.State == State.Creating).First());
DebugGraphics.LoopToDrawDebugGraphics(PathMainMenu.GetPaths().Where(p => p != null && p.State == State.Creating).First());
}
}
var firstNonNullPath = PathMainMenu.GetPaths().Where(p => p != null && p.State == State.Creating).First();
var pathIndex = PathMainMenu.GetPaths().IndexOf(firstNonNullPath);
var currentPath = firstNonNullPath.PathNum;
var currentPath = firstNonNullPath.Number;
var currentWaypoint = PathMainMenu.GetPaths()[pathIndex].Waypoints.Count + 1;
var drivingFlag = drivingFlags[waypointType.Index];
var blip = CreateWaypointBlip(pathIndex, drivingFlag);
@ -150,18 +150,12 @@ namespace SceneManager
var currentPath = PathMainMenu.GetPaths()[i];
if (PathMainMenu.GetPaths().ElementAtOrDefault(i) != null && currentPath.State == State.Creating)
{
Game.LogTrivial($"[Path Creation] Path {currentPath.PathNum} finished with {currentPath.Waypoints.Count} waypoints.");
Game.LogTrivial($"[Path Creation] Path {currentPath.Number} finished with {currentPath.Waypoints.Count} waypoints.");
Game.DisplayNotification($"~o~Scene Manager\n~g~[Success]~w~ Path {i + 1} complete.");
//currentPath.Waypoints.Last().Blip.Color = Color.OrangeRed;
//if (currentPath.Waypoints.Last().CollectorRadiusBlip)
//{
// currentPath.Waypoints.Last().CollectorRadiusBlip.Color = Color.OrangeRed;
//}
currentPath.State = State.Finished;
//currentPath.FinishPath();
currentPath.EnablePath();
currentPath.SetPathNumber(i + 1);
PathMainMenu.AddPathToPathCountList(i, currentPath.PathNum);
//PathMainMenu.AddPathToPathCountList(i, currentPath.PathNum);
// For each waypoint in the path's WaypointData, start a collector game fiber and loop while the path and waypoint exist, and while the path is enabled
foreach (Waypoint waypoint in PathMainMenu.GetPaths()[i].Waypoints)

View file

@ -9,17 +9,20 @@ namespace SceneManager
{
static class PathMainMenu
{
private static List<Path> paths = new List<Path>() { };
public static UIMenu pathMainMenu { get; private set; }
public static UIMenuItem createNewPath { get; private set; }
public static UIMenuItem deleteAllPaths;
public static UIMenuListScrollerItem<int> editPath { get; private set; }
public static UIMenuNumericScrollerItem<int> editPath = new UIMenuNumericScrollerItem<int>("Edit Path", "", 1, paths.Count, 1);
//public static UIMenuListScrollerItem<int> editPath { get; private set; }
public static UIMenuListScrollerItem<string> directOptions { get; private set; }
public static UIMenuListScrollerItem<int> directDriver { get; private set; }
public static UIMenuNumericScrollerItem<int> directDriver = new UIMenuNumericScrollerItem<int>("Direct nearest driver to path", "", 1, paths.Count, 1);
//public static UIMenuListScrollerItem<int> directDriver { get; private set; }
public static UIMenuListScrollerItem<string> dismissDriver { get; private set; }
public static UIMenuCheckboxItem disableAllPaths { get; private set; }
private static List<int> pathsNum = new List<int>();
private static List<Path> paths = new List<Path>() { };
//private static List<int> pathsNum = new List<int>();
private static List<string> dismissOptions = new List<string>() { "From path", "From waypoint", "From position" };
public enum Delete
{
@ -44,13 +47,15 @@ namespace SceneManager
pathMainMenu.AddItem(createNewPath = new UIMenuItem("Create New Path"));
createNewPath.ForeColor = Color.Gold;
pathMainMenu.AddItem(editPath = new UIMenuListScrollerItem<int>("Edit Path", "", pathsNum));
pathMainMenu.AddItem(editPath = new UIMenuNumericScrollerItem<int>("Edit Path", "", 1, paths.Count, 1));
//pathMainMenu.AddItem(editPath = new UIMenuListScrollerItem<int>("Edit Path", "", pathsNum));
editPath.ForeColor = Color.Gold;
pathMainMenu.AddItem(disableAllPaths = new UIMenuCheckboxItem("Disable All Paths", false));
pathMainMenu.AddItem(deleteAllPaths = new UIMenuItem("Delete All Paths"));
deleteAllPaths.ForeColor = Color.Gold;
pathMainMenu.AddItem(directOptions = new UIMenuListScrollerItem<string>("Direct driver to path's", "", new[] { "First waypoint", "Nearest waypoint" }));
pathMainMenu.AddItem(directDriver = new UIMenuListScrollerItem<int>("Direct nearest driver to path", "", pathsNum));
pathMainMenu.AddItem(directDriver = new UIMenuNumericScrollerItem<int>("Direct nearest driver to path", "", 1, paths.Count, 1));
//pathMainMenu.AddItem(directDriver = new UIMenuListScrollerItem<int>("Direct nearest driver to path", "", pathsNum));
directDriver.ForeColor = Color.Gold;
pathMainMenu.AddItem(dismissDriver = new UIMenuListScrollerItem<string>("Dismiss nearest driver", "", dismissOptions));
dismissDriver.ForeColor = Color.Gold;
@ -80,10 +85,10 @@ namespace SceneManager
return ref paths;
}
public static void AddPathToPathCountList(int indexToInsertAt, int pathNum)
{
pathsNum.Insert(indexToInsertAt, pathNum);
}
//public static void AddPathToPathCountList(int indexToInsertAt, int pathNum)
//{
// pathsNum.Insert(indexToInsertAt, pathNum);
//}
private static bool VehicleAndDriverValid(this Vehicle v)
{
@ -115,8 +120,8 @@ namespace SceneManager
{
// Before deleting a path, we need to dismiss any vehicles controlled by that path and remove the vehicles from ControlledVehicles
//Game.LogTrivial($"Deleting path {index+1}");
Game.LogTrivial($"Deleting path {path.PathNum}");
var pathVehicles = VehicleCollector.collectedVehicles.Where(cv => cv.Path == path.PathNum).ToList();
Game.LogTrivial($"Deleting path {path.Number}");
var pathVehicles = VehicleCollector.collectedVehicles.Where(cv => cv.Path == path.Number).ToList();
Game.LogTrivial($"Removing all vehicles on the path");
foreach (CollectedVehicle cv in pathVehicles.Where(cv => cv.Vehicle && cv.Vehicle.Driver))
@ -158,11 +163,11 @@ namespace SceneManager
paths.RemoveAt(index);
//Game.LogTrivial("pathsNum count: " + pathsNum.Count);
//Game.LogTrivial("index: " + index);
pathsNum.RemoveAt(index);
//pathsNum.RemoveAt(index);
BuildPathMenu();
pathMainMenu.Visible = true;
Game.LogTrivial($"Path {path.PathNum} deleted.");
Game.DisplayNotification($"~o~Scene Manager\n~w~Path {path.PathNum} deleted.");
Game.LogTrivial($"Path {path.Number} deleted.");
Game.DisplayNotification($"~o~Scene Manager\n~w~Path {path.Number} deleted.");
}
EditPathMenu.editPathMenu.Reset(true, true);
@ -182,8 +187,8 @@ namespace SceneManager
if (paths.ElementAtOrDefault(i) != null && paths[i].State == State.Creating)
{
//Game.LogTrivial($"pathFinished: {paths[i].PathFinished}");
Game.LogTrivial($"Resuming path {paths[i].PathNum}");
Game.DisplayNotification($"~o~Scene Manager\n~y~[Creating]~w~ Resuming path {paths[i].PathNum}");
Game.LogTrivial($"Resuming path {paths[i].Number}");
Game.DisplayNotification($"~o~Scene Manager\n~y~[Creating]~w~ Resuming path {paths[i].Number}");
break;
}
}
@ -211,7 +216,7 @@ namespace SceneManager
path.Waypoints.Clear();
}
paths.Clear();
pathsNum.Clear();
//pathsNum.Clear();
BuildPathMenu();
pathMainMenu.Visible = true;
Game.LogTrivial($"All paths deleted");
@ -256,7 +261,7 @@ namespace SceneManager
{
VehicleCollector.collectedVehicles.Add(new CollectedVehicle(nearbyVehicle, nearbyVehicle.LicensePlate, paths[directDriver.Index].Waypoints[0].Path, paths[directDriver.Index].Waypoints.Count, 1, false, false));
var collectedVehicle = VehicleCollector.collectedVehicles.Where(cv => cv.Vehicle == nearbyVehicle) as CollectedVehicle;
Game.LogTrivial($"[Direct Driver] {nearbyVehicle.Model.Name} not in collection, adding to collection for path {paths[directDriver.Index].PathNum} with {paths[directDriver.Index].Waypoints.Count} waypoints");
Game.LogTrivial($"[Direct Driver] {nearbyVehicle.Model.Name} not in collection, adding to collection for path {paths[directDriver.Index].Number} with {paths[directDriver.Index].Waypoints.Count} waypoints");
if (directOptions.SelectedItem == "First waypoint")
{