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

Renamed path 'Waypoint' list to 'Waypoints'

This commit is contained in:
Rich Dunne 2020-08-20 16:35:13 -06:00
parent 99710e7e4c
commit a1b1f68dfa
4 changed files with 57 additions and 55 deletions

View file

@ -47,7 +47,7 @@ namespace SceneManager
var firstNonNullPath = TrafficMenu.paths.Where(p => p != null && !p.PathFinished).First();
var pathIndex = TrafficMenu.paths.IndexOf(firstNonNullPath);
var currentPath = pathIndex + 1;
var currentWaypoint = TrafficMenu.paths[pathIndex].Waypoint.Count + 1;
var currentWaypoint = TrafficMenu.paths[pathIndex].Waypoints.Count + 1;
var drivingFlag = drivingFlags[waypointType.Index];
var blip = CreateWaypointBlip(pathIndex);
@ -57,11 +57,11 @@ namespace SceneManager
? (uint)World.AddSpeedZone(Game.LocalPlayer.Character.Position, 50f, MathHelper.ConvertMilesPerHourToMetersPerSecond(waypointSpeeds[waypointSpeed.Index]))
: (uint)World.AddSpeedZone(Game.LocalPlayer.Character.Position, 50f, MathHelper.ConvertKilometersPerHourToMetersPerSecond(waypointSpeeds[waypointSpeed.Index]));
TrafficMenu.paths[pathIndex].Waypoint.Add(new Waypoint(currentPath, currentWaypoint, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlag, blip, true, collectorRadii[collectorRadius.Index], yieldZone));
TrafficMenu.paths[pathIndex].Waypoints.Add(new Waypoint(currentPath, currentWaypoint, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlag, blip, true, collectorRadii[collectorRadius.Index], yieldZone));
}
else
{
TrafficMenu.paths[pathIndex].Waypoint.Add(new Waypoint(currentPath, currentWaypoint, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlag, blip));
TrafficMenu.paths[pathIndex].Waypoints.Add(new Waypoint(currentPath, currentWaypoint, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlag, blip));
}
Game.LogTrivial($"[Path {currentPath}] Waypoint {currentWaypoint} ({drivingFlag.ToString()}) added");
@ -76,16 +76,16 @@ namespace SceneManager
{
if (TrafficMenu.paths.ElementAtOrDefault(i) != null && !TrafficMenu.paths[i].PathFinished)
{
Game.LogTrivial($"[Path {i + 1}] {TrafficMenu.paths[i].Waypoint.Last().DrivingFlag.ToString()} waypoint removed");
TrafficMenu.paths[i].Waypoint.Last().Blip.Delete();
if (TrafficMenu.paths[i].Waypoint.Last().CollectorRadiusBlip)
Game.LogTrivial($"[Path {i + 1}] {TrafficMenu.paths[i].Waypoints.Last().DrivingFlag.ToString()} waypoint removed");
TrafficMenu.paths[i].Waypoints.Last().Blip.Delete();
if (TrafficMenu.paths[i].Waypoints.Last().CollectorRadiusBlip)
{
TrafficMenu.paths[i].Waypoint.Last().CollectorRadiusBlip.Delete();
TrafficMenu.paths[i].Waypoints.Last().CollectorRadiusBlip.Delete();
}
TrafficMenu.paths[i].Waypoint.RemoveAt(TrafficMenu.paths[i].Waypoint.IndexOf(TrafficMenu.paths[i].Waypoint.Last()));
TrafficMenu.paths[i].Waypoints.RemoveAt(TrafficMenu.paths[i].Waypoints.IndexOf(TrafficMenu.paths[i].Waypoints.Last()));
// If the path has no waypoints, disable the menu option to remove a waypoint
if (TrafficMenu.paths[i].Waypoint.Count == 0)
if (TrafficMenu.paths[i].Waypoints.Count == 0)
{
trafficRemoveWaypoint.Enabled = false;
}
@ -98,28 +98,29 @@ namespace SceneManager
// Loop through each path and find the first one which isn't finished
for (int i = 0; i < TrafficMenu.paths.Count; i++)
{
if (TrafficMenu.paths.ElementAtOrDefault(i) != null && !TrafficMenu.paths[i].PathFinished)
var currentPath = TrafficMenu.paths[i];
if (TrafficMenu.paths.ElementAtOrDefault(i) != null && !currentPath.PathFinished)
{
// If the path has one stop waypoint or at least two waypoints, finish the path and start the vehicle collector loop, else show user the error and delete any waypoints they made and clear the invalid path
if (TrafficMenu.paths[i].Waypoint.Count >= 2 || (TrafficMenu.paths[i].Waypoint.Count == 1 && TrafficMenu.paths[i].Waypoint[0].DrivingFlag == VehicleDrivingFlags.StopAtDestination))
if (currentPath.Waypoints.Count >= 2 || (currentPath.Waypoints.Count == 1 && currentPath.Waypoints[0].DrivingFlag == VehicleDrivingFlags.StopAtDestination))
{
Game.LogTrivial($"[Path Creation] Path {i + 1} finished with {TrafficMenu.paths[i].Waypoint.Count} waypoints.");
Game.LogTrivial($"[Path Creation] Path {i + 1} finished with {currentPath.Waypoints.Count} waypoints.");
Game.DisplayNotification($"~o~Scene Manager\n~g~[Success]~w~ Path {i + 1} complete.");
TrafficMenu.paths[i].Waypoint.Last().Blip.Color = Color.OrangeRed;
if (TrafficMenu.paths[i].Waypoint.Last().CollectorRadiusBlip)
currentPath.Waypoints.Last().Blip.Color = Color.OrangeRed;
if (currentPath.Waypoints.Last().CollectorRadiusBlip)
{
TrafficMenu.paths[i].Waypoint.Last().CollectorRadiusBlip.Color = Color.OrangeRed;
currentPath.Waypoints.Last().CollectorRadiusBlip.Color = Color.OrangeRed;
}
TrafficMenu.paths[i].PathFinished = true;
TrafficMenu.paths[i].PathDisabled = false;
TrafficMenu.paths[i].PathNum = i + 1;
TrafficMenu.pathsNum.Insert(i, TrafficMenu.paths[i].PathNum);
currentPath.FinishPath();
currentPath.EnablePath();
currentPath.SetPathNumber(i + 1);
TrafficMenu.pathsNum.Insert(i, currentPath.PathNum);
//GameFiber InitialWaypointVehicleCollectorFiber = new GameFiber(() => TrafficPathing.InitialWaypointVehicleCollector(paths[i]));
//InitialWaypointVehicleCollectorFiber.Start();
// 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 wd in TrafficMenu.paths[i].Waypoint)
foreach (Waypoint wd in TrafficMenu.paths[i].Waypoints)
{
GameFiber WaypointVehicleCollectorFiber = new GameFiber(() => TrafficPathing.WaypointVehicleCollector(TrafficMenu.paths, TrafficMenu.paths[i], wd));
WaypointVehicleCollectorFiber.Start();
@ -138,7 +139,7 @@ namespace SceneManager
{
Game.LogTrivial($"[Path Error] A minimum of 2 waypoints is required.");
Game.DisplayNotification($"~o~Scene Manager\n~r~[Error]~w~ A minimum of 2 waypoints or one stop waypoint is required to create a path.");
foreach (Waypoint wp in TrafficMenu.paths[i].Waypoint)
foreach (Waypoint wp in TrafficMenu.paths[i].Waypoints)
{
wp.Blip.Delete();
if (wp.CollectorRadiusBlip)
@ -146,7 +147,7 @@ namespace SceneManager
wp.CollectorRadiusBlip.Delete();
}
}
TrafficMenu.paths[i].Waypoint.Clear();
TrafficMenu.paths[i].Waypoints.Clear();
TrafficMenu.paths.RemoveAt(i);
break;
}
@ -186,7 +187,7 @@ namespace SceneManager
Sprite = (BlipSprite)spriteNumericalEnum
};
if (TrafficMenu.paths[pathIndex].Waypoint.Count == 0)
if (TrafficMenu.paths[pathIndex].Waypoints.Count == 0)
{
blip.Color = Color.Orange;
}

View file

@ -103,7 +103,7 @@ namespace SceneManager
// Remove the speed zone so cars don't continue to be affected after the path is deleted
Game.LogTrivial($"Removing yield zone and waypoint blips");
foreach (Waypoint wp in path.Waypoint)
foreach (Waypoint wp in path.Waypoints)
{
if (wp.YieldZone != 0)
{
@ -120,7 +120,7 @@ namespace SceneManager
}
Game.LogTrivial($"Clearing path.WaypointData");
path.Waypoint.Clear();
path.Waypoints.Clear();
// Manipulating the menu to reflect specific paths being deleted
if (pathsToDelete == "Single")
{
@ -190,7 +190,7 @@ namespace SceneManager
}
foreach (Path path in paths)
{
path.Waypoint.Clear();
path.Waypoints.Clear();
}
paths.Clear();
pathsNum.Clear();
@ -209,24 +209,25 @@ namespace SceneManager
if (nearbyVehicle.IsInCollectedVehicles())
{
var vehicle = TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate];
var nearestWaypoint = paths[directDriver.Index].Waypoints.OrderBy(wp => wp.Position).Take(1) as Waypoint;
Game.LogTrivial($"[Direct Driver] {nearbyVehicle.Model.Name} already in collection. Clearing tasks.");
nearbyVehicle.Driver.Tasks.Clear();
vehicle.Path = paths[directDriver.Index].Waypoint[0].Path;
vehicle.TotalWaypoints = paths[directDriver.Index].Waypoint.Count;
vehicle.Path = paths[directDriver.Index].Waypoints[0].Path;
vehicle.TotalWaypoints = paths[directDriver.Index].Waypoints.Count;
vehicle.CurrentWaypoint = 1;
vehicle.DismissNow = true;
vehicle.StoppedAtWaypoint = false;
vehicle.Redirected = true;
GameFiber DirectTaskFiber = new GameFiber(() => TrafficPathing.DirectTask(vehicle, paths[directDriver.Index].Waypoint));
GameFiber DirectTaskFiber = new GameFiber(() => TrafficPathing.DirectTask(vehicle, paths[directDriver.Index].Waypoints));
DirectTaskFiber.Start();
}
else
{
TrafficPathing.collectedVehicles.Add(nearbyVehicle.LicensePlate, new CollectedVehicle(nearbyVehicle, nearbyVehicle.LicensePlate, paths[directDriver.Index].Waypoint[0].Path, paths[directDriver.Index].Waypoint.Count, 1, false, false, true));
Game.LogTrivial($"[Direct Driver] {nearbyVehicle.Model.Name} not in collection, adding to collection for path {paths[directDriver.Index].Waypoint[0].Path} with {paths[directDriver.Index].Waypoint.Count} waypoints");
TrafficPathing.collectedVehicles.Add(nearbyVehicle.LicensePlate, new CollectedVehicle(nearbyVehicle, nearbyVehicle.LicensePlate, paths[directDriver.Index].Waypoints[0].Path, paths[directDriver.Index].Waypoints.Count, 1, false, false, true));
Game.LogTrivial($"[Direct Driver] {nearbyVehicle.Model.Name} not in collection, adding to collection for path {paths[directDriver.Index].Waypoints[0].Path} with {paths[directDriver.Index].Waypoints.Count} waypoints");
GameFiber DirectTaskFiber = new GameFiber(() => TrafficPathing.DirectTask(TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate], paths[directDriver.Index].Waypoint));
GameFiber DirectTaskFiber = new GameFiber(() => TrafficPathing.DirectTask(TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate], paths[directDriver.Index].Waypoints));
DirectTaskFiber.Start();
}
}
@ -316,8 +317,8 @@ namespace SceneManager
{
foreach (Path path in paths)
{
path.PathDisabled = true;
foreach (Waypoint waypoint in path.Waypoint)
path.DisablePath();
foreach (Waypoint waypoint in path.Waypoints)
{
waypoint.Blip.Alpha = 0.5f;
if (waypoint.CollectorRadiusBlip)
@ -332,8 +333,8 @@ namespace SceneManager
{
foreach (Path path in paths)
{
path.PathDisabled = false;
foreach (Waypoint waypoint in path.Waypoint)
path.EnablePath();
foreach (Waypoint waypoint in path.Waypoints)
{
waypoint.Blip.Alpha = 1f;
if (waypoint.CollectorRadiusBlip)