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

Updated code to reference Path State enum based on recent refactor

This commit is contained in:
Rich Dunne 2020-08-26 16:16:31 -06:00
parent 338fa61c94
commit 773f76a7de
2 changed files with 17 additions and 14 deletions

View file

@ -76,20 +76,20 @@ namespace SceneManager
}); });
} }
} }
else if(anyPathsExist && !PathMainMenu.GetPaths().Any(p => p != null && !p.PathFinished)) else if(anyPathsExist && !PathMainMenu.GetPaths().Any(p => p != null && p.State == State.Creating))
{ {
AddNewPathToPathsCollection(PathMainMenu.GetPaths(), PathMainMenu.GetPaths().IndexOf(PathMainMenu.GetPaths().Where(p => p.PathFinished).First()) + 1); AddNewPathToPathsCollection(PathMainMenu.GetPaths(), PathMainMenu.GetPaths().IndexOf(PathMainMenu.GetPaths().Where(p => p.State == State.Finished).First()) + 1);
if (SettingsMenu.debugGraphics.Checked) if (SettingsMenu.debugGraphics.Checked)
{ {
GameFiber.StartNew(() => GameFiber.StartNew(() =>
{ {
DebugGraphics.LoopToDrawDebugGraphics(SettingsMenu.debugGraphics, PathMainMenu.GetPaths().Where(p => p != null && !p.PathFinished).First()); DebugGraphics.LoopToDrawDebugGraphics(SettingsMenu.debugGraphics, PathMainMenu.GetPaths().Where(p => p != null && p.State == State.Creating).First());
}); });
} }
} }
var firstNonNullPath = PathMainMenu.GetPaths().Where(p => p != null && !p.PathFinished).First(); var firstNonNullPath = PathMainMenu.GetPaths().Where(p => p != null && p.State == State.Creating).First();
var pathIndex = PathMainMenu.GetPaths().IndexOf(firstNonNullPath); var pathIndex = PathMainMenu.GetPaths().IndexOf(firstNonNullPath);
var currentPath = firstNonNullPath.PathNum; var currentPath = firstNonNullPath.PathNum;
var currentWaypoint = PathMainMenu.GetPaths()[pathIndex].Waypoints.Count + 1; var currentWaypoint = PathMainMenu.GetPaths()[pathIndex].Waypoints.Count + 1;
@ -120,7 +120,7 @@ namespace SceneManager
// Loop through each path and find the first one which isn't finished, then delete the path's last waypoint and corresponding blip // 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.GetPaths().Count; i++)
{ {
if (PathMainMenu.GetPaths().ElementAtOrDefault(i) != null && !PathMainMenu.GetPaths()[i].PathFinished) if (PathMainMenu.GetPaths().ElementAtOrDefault(i) != null && PathMainMenu.GetPaths()[i].State == State.Creating)
{ {
Game.LogTrivial($"[Path {i + 1}] {PathMainMenu.GetPaths()[i].Waypoints.Last().DrivingFlag.ToString()} waypoint removed"); Game.LogTrivial($"[Path {i + 1}] {PathMainMenu.GetPaths()[i].Waypoints.Last().DrivingFlag.ToString()} waypoint removed");
PathMainMenu.GetPaths()[i].Waypoints.Last().Blip.Delete(); PathMainMenu.GetPaths()[i].Waypoints.Last().Blip.Delete();
@ -150,7 +150,7 @@ namespace SceneManager
for (int i = 0; i < PathMainMenu.GetPaths().Count; i++) for (int i = 0; i < PathMainMenu.GetPaths().Count; i++)
{ {
var currentPath = PathMainMenu.GetPaths()[i]; var currentPath = PathMainMenu.GetPaths()[i];
if (PathMainMenu.GetPaths().ElementAtOrDefault(i) != null && !currentPath.PathFinished) 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.PathNum} finished with {currentPath.Waypoints.Count} waypoints.");
Game.DisplayNotification($"~o~Scene Manager\n~g~[Success]~w~ Path {i + 1} complete."); Game.DisplayNotification($"~o~Scene Manager\n~g~[Success]~w~ Path {i + 1} complete.");
@ -159,7 +159,8 @@ namespace SceneManager
{ {
currentPath.Waypoints.Last().CollectorRadiusBlip.Color = Color.OrangeRed; currentPath.Waypoints.Last().CollectorRadiusBlip.Color = Color.OrangeRed;
} }
currentPath.FinishPath(); currentPath.State = State.Finished;
//currentPath.FinishPath();
currentPath.EnablePath(); currentPath.EnablePath();
currentPath.SetPathNumber(i + 1); currentPath.SetPathNumber(i + 1);
PathMainMenu.AddPathToPathCountList(i, currentPath.PathNum); PathMainMenu.AddPathToPathCountList(i, currentPath.PathNum);
@ -172,9 +173,10 @@ namespace SceneManager
} }
MenuManager.menuPool.CloseAllMenus(); MenuManager.menuPool.CloseAllMenus();
PathMainMenu.pathMainMenu.Clear(); pathCreationMenu.Reset(true, true); // Trying to see if we can get away with resetting the menu instead of rebuilding it
PathMainMenu.BuildPathMenu(); //PathMainMenu.pathMainMenu.Clear();
trafficEndPath.Enabled = false; //PathMainMenu.BuildPathMenu();
//trafficEndPath.Enabled = false;
PathMainMenu.pathMainMenu.Visible = true; PathMainMenu.pathMainMenu.Visible = true;
break; break;
} }
@ -239,7 +241,7 @@ namespace SceneManager
var pathNum = pathIndex + 1; var pathNum = pathIndex + 1;
Game.LogTrivial($"Creating path {pathNum}"); Game.LogTrivial($"Creating path {pathNum}");
Game.DisplayNotification($"~o~Scene Manager\n~y~[Creating]~w~ Path {pathNum} started."); Game.DisplayNotification($"~o~Scene Manager\n~y~[Creating]~w~ Path {pathNum} started.");
paths.Insert(pathIndex, new Path(pathNum, false)); paths.Insert(pathIndex, new Path(pathNum, State.Creating));
trafficRemoveWaypoint.Enabled = false; trafficRemoveWaypoint.Enabled = false;
trafficEndPath.Enabled = false; trafficEndPath.Enabled = false;
} }

View file

@ -21,15 +21,16 @@ namespace SceneManager
public Path(int pathNum, bool pathFinished, bool pathDisabled, List<Waypoint> waypoints) public Path(int pathNum, bool pathFinished, bool pathDisabled, List<Waypoint> waypoints)
{ {
PathNum = pathNum; PathNum = pathNum;
PathFinished = pathFinished; //PathFinished = pathFinished;
IsEnabled = pathDisabled; IsEnabled = pathDisabled;
Waypoints = waypoints; Waypoints = waypoints;
} }
public Path(int pathNum, bool pathFinished) public Path(int pathNum, State pathState)
{ {
PathNum = pathNum; PathNum = pathNum;
PathFinished = pathFinished; State = pathState;
//PathFinished = pathFinished;
} }
public void SetPathStatus(bool status) public void SetPathStatus(bool status)