mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 15:40:29 +01:00
Added separate menu option for collector waypoint speed zone.
This commit is contained in:
parent
646498bbc5
commit
54c2bd8c12
3 changed files with 53 additions and 24 deletions
|
|
@ -18,8 +18,9 @@ namespace SceneManager
|
|||
public static UIMenuNumericScrollerItem<int> editWaypoint;
|
||||
private static UIMenuListScrollerItem<string> changeWaypointType = new UIMenuListScrollerItem<string>("New Waypoint Type", "", waypointTypes);
|
||||
private static UIMenuNumericScrollerItem<int> changeWaypointSpeed;
|
||||
private static UIMenuNumericScrollerItem<int> changeCollectorRadius = new UIMenuNumericScrollerItem<int>("New Collection Radius", "The distance from this waypoint in meters vehicles will be collected", 1, 50, 1);
|
||||
private static UIMenuCheckboxItem collectorWaypoint = new UIMenuCheckboxItem("Collector", true, "If this waypoint will collect vehicles to follow the path");
|
||||
private static UIMenuNumericScrollerItem<int> changeCollectorRadius = new UIMenuNumericScrollerItem<int>("New Collection Radius", "The distance from this waypoint (in meters) vehicles will be collected", 1, 50, 1);
|
||||
private static UIMenuNumericScrollerItem<int> changeSpeedZoneRadius = new UIMenuNumericScrollerItem<int>("New Speed Zone Radius", "The distance from this collector waypoint (in meters) non-collected vehicles will drive at this waypoint's speed", 1, 50, 1);
|
||||
private static UIMenuCheckboxItem updateWaypointPosition;
|
||||
|
||||
internal static void InstantiateMenu()
|
||||
|
|
@ -47,7 +48,6 @@ namespace SceneManager
|
|||
editWaypointMenu.AddItem(changeWaypointType);
|
||||
changeWaypointType.Index = Array.IndexOf(drivingFlags, PathMainMenu.GetPaths()[PathMainMenu.editPath.Index].Waypoints[editWaypoint.Index].DrivingFlag);
|
||||
|
||||
//Game.LogTrivial($"Waypoint speed: {PathMainMenu.GetPaths()[PathMainMenu.editPath.Index].Waypoints[editWaypoint.Index].Speed}");
|
||||
editWaypointMenu.AddItem(changeWaypointSpeed = new UIMenuNumericScrollerItem<int>("New Waypoint Speed", $"How fast the AI will drive to the waypoint in ~b~{SettingsMenu.speedUnits.SelectedItem}", 5, 80, 5));
|
||||
changeWaypointSpeed.Value = (int)MathHelper.ConvertMetersPerSecondToMilesPerHour(PathMainMenu.GetPaths()[PathMainMenu.editPath.Index].Waypoints[editWaypoint.Index].Speed);
|
||||
|
||||
|
|
@ -58,6 +58,14 @@ namespace SceneManager
|
|||
? (int)PathMainMenu.GetPaths()[PathMainMenu.editPath.Index].Waypoints[editWaypoint.Index].CollectorRadius
|
||||
: changeCollectorRadius.Minimum;
|
||||
|
||||
editWaypointMenu.AddItem(changeSpeedZoneRadius);
|
||||
changeSpeedZoneRadius.Value = PathMainMenu.GetPaths()[PathMainMenu.editPath.Index].Waypoints[editWaypoint.Index].CollectorRadius != 0
|
||||
? (int)PathMainMenu.GetPaths()[PathMainMenu.editPath.Index].Waypoints[editWaypoint.Index].SpeedZoneRadius
|
||||
: changeSpeedZoneRadius.Minimum;
|
||||
|
||||
changeCollectorRadius.Enabled = collectorWaypoint.Checked ? true : false;
|
||||
changeSpeedZoneRadius.Enabled = collectorWaypoint.Checked ? true : false;
|
||||
|
||||
editWaypointMenu.AddItem(updateWaypointPosition = new UIMenuCheckboxItem("Update Waypoint Position", false));
|
||||
editWaypointMenu.AddItem(editUpdateWaypoint = new UIMenuItem("Update Waypoint"));
|
||||
editUpdateWaypoint.ForeColor = Color.Gold;
|
||||
|
|
@ -78,10 +86,10 @@ namespace SceneManager
|
|||
if(scrollerItem == editWaypoint)
|
||||
{
|
||||
changeWaypointType.Index = Array.IndexOf(drivingFlags, PathMainMenu.GetPaths()[PathMainMenu.editPath.Index].Waypoints[editWaypoint.Index].DrivingFlag);
|
||||
//changeWaypointSpeed.Index = Array.IndexOf(waypointSpeeds, MathHelper.ConvertMetersPerSecondToMilesPerHour(PathMainMenu.GetPaths()[PathMainMenu.editPath.Index].Waypoints[editWaypoint.Index].Speed));
|
||||
changeWaypointSpeed.Value = (int)MathHelper.ConvertMetersPerSecondToMilesPerHour(PathMainMenu.GetPaths()[PathMainMenu.editPath.Index].Waypoints[editWaypoint.Index].Speed);
|
||||
collectorWaypoint.Checked = PathMainMenu.GetPaths()[PathMainMenu.editPath.Index].Waypoints[editWaypoint.Index].IsCollector;
|
||||
changeCollectorRadius.Enabled = collectorWaypoint.Checked ? true : false;
|
||||
changeSpeedZoneRadius.Enabled = collectorWaypoint.Checked ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -90,6 +98,7 @@ namespace SceneManager
|
|||
if (checkboxItem == collectorWaypoint)
|
||||
{
|
||||
changeCollectorRadius.Enabled = collectorWaypoint.Checked ? true : false;
|
||||
changeSpeedZoneRadius.Enabled = collectorWaypoint.Checked ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +109,7 @@ namespace SceneManager
|
|||
|
||||
if (selectedItem == editUpdateWaypoint)
|
||||
{
|
||||
currentWaypoint.UpdateWaypoint(currentWaypoint, drivingFlags[changeWaypointType.Index], SetDriveSpeedForWaypoint(), collectorWaypoint.Checked, changeCollectorRadius.Value, updateWaypointPosition.Checked);
|
||||
currentWaypoint.UpdateWaypoint(currentWaypoint, drivingFlags[changeWaypointType.Index], SetDriveSpeedForWaypoint(), collectorWaypoint.Checked, changeCollectorRadius.Value, changeSpeedZoneRadius.Value, updateWaypointPosition.Checked);
|
||||
Game.LogTrivial($"Updated path {currentPath.PathNum} waypoint {currentWaypoint.Number}: Driving flag is {drivingFlags[changeWaypointType.Index].ToString()}, speed is {changeWaypointSpeed.Value}, collector is {currentWaypoint.IsCollector}");
|
||||
|
||||
if (currentPath.Waypoints.Count < 2 && currentPath.Waypoints[0].DrivingFlag == VehicleDrivingFlags.StopAtDestination)
|
||||
|
|
|
|||
|
|
@ -16,8 +16,9 @@ namespace SceneManager
|
|||
private static UIMenuItem trafficAddWaypoint, trafficRemoveWaypoint, trafficEndPath;
|
||||
public static UIMenuListScrollerItem<string> waypointType = new UIMenuListScrollerItem<string>("Waypoint Type", "", waypointTypes);
|
||||
private static UIMenuNumericScrollerItem<int> waypointSpeed;
|
||||
public static UIMenuNumericScrollerItem<int> collectorRadius = new UIMenuNumericScrollerItem<int>("Collection Radius", "The distance from this waypoint in meters vehicles will be collected", 1, 50, 1);
|
||||
public static UIMenuCheckboxItem collectorWaypoint = new UIMenuCheckboxItem("Collector", true, "If this waypoint will collect vehicles to follow the path");
|
||||
public static UIMenuNumericScrollerItem<int> collectorRadius = new UIMenuNumericScrollerItem<int>("Collection Radius", "The distance from this waypoint (in meters) vehicles will be collected", 1, 50, 1);
|
||||
public static UIMenuNumericScrollerItem<int> speedZoneRadius = new UIMenuNumericScrollerItem<int>("Speed Zone Radius", "The distance from this collector waypoint (in meters) non-collected vehicles will drive at this waypoint's speed", 1, 50, 1);
|
||||
|
||||
internal static void InstantiateMenu()
|
||||
{
|
||||
|
|
@ -34,6 +35,8 @@ namespace SceneManager
|
|||
pathCreationMenu.AddItem(collectorWaypoint);
|
||||
pathCreationMenu.AddItem(collectorRadius);
|
||||
collectorRadius.Index = 0;
|
||||
pathCreationMenu.AddItem(speedZoneRadius);
|
||||
speedZoneRadius.Index = 0;
|
||||
pathCreationMenu.AddItem(trafficAddWaypoint = new UIMenuItem("Add waypoint"));
|
||||
trafficAddWaypoint.ForeColor = Color.Gold;
|
||||
pathCreationMenu.AddItem(trafficRemoveWaypoint = new UIMenuItem("Remove last waypoint"));
|
||||
|
|
@ -53,6 +56,7 @@ namespace SceneManager
|
|||
if(checkboxItem == collectorWaypoint)
|
||||
{
|
||||
collectorRadius.Enabled = collectorWaypoint.Checked ? true : false;
|
||||
speedZoneRadius.Enabled = collectorWaypoint.Checked ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -70,10 +74,7 @@ namespace SceneManager
|
|||
|
||||
if (SettingsMenu.debugGraphics.Checked)
|
||||
{
|
||||
GameFiber.StartNew(() =>
|
||||
{
|
||||
DebugGraphics.LoopToDrawDebugGraphics(SettingsMenu.debugGraphics, PathMainMenu.GetPaths()[0]);
|
||||
});
|
||||
DebugGraphics.LoopToDrawDebugGraphics(SettingsMenu.debugGraphics, PathMainMenu.GetPaths()[0]);
|
||||
}
|
||||
}
|
||||
else if(anyPathsExist && !PathMainMenu.GetPaths().Any(p => p != null && p.State == State.Creating))
|
||||
|
|
@ -82,10 +83,7 @@ namespace SceneManager
|
|||
|
||||
if (SettingsMenu.debugGraphics.Checked)
|
||||
{
|
||||
GameFiber.StartNew(() =>
|
||||
{
|
||||
DebugGraphics.LoopToDrawDebugGraphics(SettingsMenu.debugGraphics, PathMainMenu.GetPaths().Where(p => p != null && p.State == State.Creating).First());
|
||||
});
|
||||
DebugGraphics.LoopToDrawDebugGraphics(SettingsMenu.debugGraphics, PathMainMenu.GetPaths().Where(p => p != null && p.State == State.Creating).First());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -99,10 +97,9 @@ namespace SceneManager
|
|||
if (collectorWaypoint.Checked)
|
||||
{
|
||||
var yieldZone = SettingsMenu.speedUnits.SelectedItem == SettingsMenu.SpeedUnitsOfMeasure.MPH
|
||||
? World.AddSpeedZone(Game.LocalPlayer.Character.Position, 50f, MathHelper.ConvertMilesPerHourToMetersPerSecond(waypointSpeed.Value))
|
||||
: World.AddSpeedZone(Game.LocalPlayer.Character.Position, 50f, MathHelper.ConvertKilometersPerHourToMetersPerSecond(waypointSpeed.Value));
|
||||
|
||||
PathMainMenu.GetPaths()[pathIndex].Waypoints.Add(new Waypoint(currentPath, currentWaypoint, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlag, blip, true, collectorRadius.Value, yieldZone));
|
||||
? World.AddSpeedZone(Game.LocalPlayer.Character.Position, speedZoneRadius.Value, MathHelper.ConvertMilesPerHourToMetersPerSecond(waypointSpeed.Value))
|
||||
: World.AddSpeedZone(Game.LocalPlayer.Character.Position, speedZoneRadius.Value, MathHelper.ConvertKilometersPerHourToMetersPerSecond(waypointSpeed.Value));
|
||||
PathMainMenu.GetPaths()[pathIndex].Waypoints.Add(new Waypoint(currentPath, currentWaypoint, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlag, blip, true, collectorRadius.Value, speedZoneRadius.Value, yieldZone));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -166,9 +163,9 @@ namespace SceneManager
|
|||
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 wd in PathMainMenu.GetPaths()[i].Waypoints)
|
||||
foreach (Waypoint waypoint in PathMainMenu.GetPaths()[i].Waypoints)
|
||||
{
|
||||
GameFiber WaypointVehicleCollectorFiber = new GameFiber(() => VehicleCollector.StartCollectingAtWaypoint(PathMainMenu.GetPaths(), PathMainMenu.GetPaths()[i], wd));
|
||||
GameFiber WaypointVehicleCollectorFiber = new GameFiber(() => VehicleCollector.StartCollectingAtWaypoint(PathMainMenu.GetPaths(), PathMainMenu.GetPaths()[i], waypoint));
|
||||
WaypointVehicleCollectorFiber.Start();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue