mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-12 08:00:30 +01:00
Merge V2.1.1 release (#3)
* Mouse can now be used to fully navigate menus * Added check for driver's current vehicle when releasing from Stop waypoint in case the ped is not in a vehicle. * Lines are now only drawn between waypoint markers under the same conditions that waypoint markers are drawn * Updated marker position to be player's mouse position * Version update * Added logic to update waypoint position during driving task if the waypoint position was changed before the driver arrived. * Removed unused usings. Refactored debug statements to use Game.LogTrivial instead of Logger.Log * Removed class * Removed Logger class * Consolidated all custom enums to this class. Added default waypoint settings from .ini * Modified a hint message * Fixed collector options not being enabled/disabled when Collector box is checked * Refactored AITasking into CollectedVehicle. * Updated reference to vehicle tasking based on AITasking refactor. Fixed speed zone radius not updating correctly. * Version update * Refactored AITasking into CollectedVehicle * Added check for CollectorRadius being more than SpeedZoneRadius. Added debug messages when values are reset to default. * Added hint message if player tries to edit waypoints while 3D waypoints are disabled * Fixed a bug where a 3D waypoint marker would be drawn even if 3D waypoints were disabled * Removed unnecessary property setting when a vehicle is being removed from a path. * Added a check for if the driver loses their task and reassigns it. * Fixed a bug where the 3D line between waypoints was still being drawn even though 3D waypoints were disabled in the settings menu. * Updated version * Added console command to show info about collected vehicles. * Added ConsoleCommand class, removed AITasking class. * Removed class after refactoring into CollectedVehicle * Update README.md * Update README.md * Added ini setting for Advanced Barrier Options. Added enum for TrafficLight state. Added debug message for invalid barriers. * Updated version * Added MousePositionInWorld and RNUIMouseInputHandler classes * Fixed a crash when a collected ped is arrested. * Refactored to implement RNUIMouseInputHandler class. * Removed unused method. * Updated version * Disabled deletion/creation of shadow barrier and re-enabled updating position based on mouse position. * Added check for Driver's current vehicle in driving loop in case the Driver exited Vehicle at some point. Adjusted some guard clause logic and log messages. * Removed unused variable * Renamed some methods to improve clarity * Updated version.
This commit is contained in:
parent
d73ae601e7
commit
8bc4de3528
21 changed files with 1818 additions and 1083 deletions
|
|
@ -2,6 +2,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Net.Configuration;
|
||||
using System.Windows.Forms;
|
||||
using Rage;
|
||||
using RAGENativeUI;
|
||||
using RAGENativeUI.Elements;
|
||||
|
|
@ -10,22 +12,24 @@ namespace SceneManager
|
|||
{
|
||||
class PathCreationMenu
|
||||
{
|
||||
private static VehicleDrivingFlags[] drivingFlags = new VehicleDrivingFlags[] { VehicleDrivingFlags.Normal, VehicleDrivingFlags.IgnorePathFinding, VehicleDrivingFlags.StopAtDestination }; // Implement custom driving flag for normal
|
||||
private static string[] waypointTypes = new string[] { "Drive To (Normal)", "Drive To (Direct)", "Stop" };
|
||||
internal static UIMenu pathCreationMenu = new UIMenu("Scene Manager", "~o~Path Creation Menu");
|
||||
private static UIMenuItem trafficAddWaypoint = new UIMenuItem("Add waypoint"), trafficRemoveWaypoint = new UIMenuItem("Remove last waypoint"), trafficEndPath = new UIMenuItem("End path creation");
|
||||
internal static UIMenuListScrollerItem<string> waypointType = new UIMenuListScrollerItem<string>("Waypoint Type", $"~b~Drive To (Normal): ~w~AI obeys traffic as much as possible{Environment.NewLine}~b~Drive To (Direct): ~w~AI ignores pathfinding rules{Environment.NewLine}~b~Stop: ~w~AI stops at the waypoint until dismissed", waypointTypes);
|
||||
private static UIMenuNumericScrollerItem<int> waypointSpeed;
|
||||
internal static UIMenuNumericScrollerItem<int> waypointSpeed;
|
||||
internal static UIMenuCheckboxItem stopWaypointType = new UIMenuCheckboxItem("Is this a Stop waypoint?", false, "If checked, vehicles will drive to this waypoint, then stop.");
|
||||
internal static UIMenuCheckboxItem directWaypointBehavior = new UIMenuCheckboxItem("Drive directly to waypoint?", false, "If checked, vehicles will ignore traffic rules and drive directly to this waypoint.");
|
||||
internal static UIMenuCheckboxItem collectorWaypoint = new UIMenuCheckboxItem("Collector", true, "If checked, this waypoint will collect vehicles to follow the path. Your path's first waypoint ~b~must~w~ be a collector.");
|
||||
internal static UIMenuNumericScrollerItem<int> collectorRadius = new UIMenuNumericScrollerItem<int>("Collection Radius", "The distance from this waypoint (in meters) vehicles will be collected", 1, 50, 1);
|
||||
internal 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", 5, 200, 5);
|
||||
private static List<UIMenuItem> menuItems = new List<UIMenuItem> {collectorWaypoint, collectorRadius, speedZoneRadius, stopWaypointType, directWaypointBehavior, waypointSpeed, trafficAddWaypoint, trafficRemoveWaypoint, trafficEndPath };
|
||||
|
||||
internal static void InstantiateMenu()
|
||||
{
|
||||
pathCreationMenu.ParentMenu = PathMainMenu.pathMainMenu;
|
||||
MenuManager.menuPool.Add(pathCreationMenu);
|
||||
pathCreationMenu.OnItemSelect += PathCreation_OnItemSelected;
|
||||
pathCreationMenu.OnCheckboxChange += PathCreation_OnCheckboxChanged;
|
||||
pathCreationMenu.OnScrollerChange += PathCreation_OnScrollerChanged;
|
||||
pathCreationMenu.OnMenuOpen += PathCreation_OnMenuOpen;
|
||||
}
|
||||
|
||||
internal static void BuildPathCreationMenu()
|
||||
|
|
@ -35,18 +39,20 @@ namespace SceneManager
|
|||
collectorWaypoint.Checked = true;
|
||||
|
||||
pathCreationMenu.AddItem(collectorRadius);
|
||||
collectorRadius.Index = 0;
|
||||
collectorRadius.Index = Settings.CollectorRadius - 1;
|
||||
collectorRadius.Enabled = true;
|
||||
|
||||
pathCreationMenu.AddItem(speedZoneRadius);
|
||||
speedZoneRadius.Index = 0;
|
||||
speedZoneRadius.Index = (Settings.SpeedZoneRadius / 5) - 1;
|
||||
speedZoneRadius.Enabled = true;
|
||||
|
||||
pathCreationMenu.AddItem(stopWaypointType);
|
||||
stopWaypointType.Checked = Settings.StopWaypoint;
|
||||
pathCreationMenu.AddItem(directWaypointBehavior);
|
||||
directWaypointBehavior.Checked = Settings.DirectDrivingBehavior;
|
||||
|
||||
pathCreationMenu.AddItem(waypointSpeed = new UIMenuNumericScrollerItem<int>("Waypoint Speed", $"How fast the AI will drive to this waypoint in ~b~{SettingsMenu.speedUnits.SelectedItem}", 5, 100, 5));
|
||||
waypointSpeed.Index = 0;
|
||||
waypointSpeed.Index = (Settings.WaypointSpeed / 5) - 1;
|
||||
|
||||
pathCreationMenu.AddItem(trafficAddWaypoint);
|
||||
trafficAddWaypoint.ForeColor = Color.Gold;
|
||||
|
|
@ -60,206 +66,175 @@ namespace SceneManager
|
|||
trafficEndPath.Enabled = false;
|
||||
|
||||
pathCreationMenu.RefreshIndex();
|
||||
pathCreationMenu.OnItemSelect += PathCreation_OnItemSelected;
|
||||
pathCreationMenu.OnCheckboxChange += PathCreation_OnCheckboxChanged;
|
||||
pathCreationMenu.OnScrollerChange += PathCreation_OnScrollerChanged;
|
||||
}
|
||||
|
||||
private static void PathCreation_OnCheckboxChanged(UIMenu sender, UIMenuCheckboxItem checkboxItem, bool @checked)
|
||||
private static void UpdateCollectorMenuOptionsStatus()
|
||||
{
|
||||
if(checkboxItem == collectorWaypoint)
|
||||
if (collectorWaypoint.Checked)
|
||||
{
|
||||
collectorRadius.Enabled = collectorWaypoint.Checked ? true : false;
|
||||
speedZoneRadius.Enabled = collectorWaypoint.Checked ? true : false;
|
||||
collectorRadius.Enabled = true;
|
||||
speedZoneRadius.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
collectorRadius.Enabled = false;
|
||||
speedZoneRadius.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void PathCreation_OnItemSelected(UIMenu sender, UIMenuItem selectedItem, int index)
|
||||
{
|
||||
if (selectedItem == trafficAddWaypoint)
|
||||
private static void AddNewWaypoint()
|
||||
{
|
||||
var anyPathsExist = PathMainMenu.paths.Count > 0;
|
||||
var waypointPosition = MousePositionInWorld.GetPosition;
|
||||
|
||||
if (!anyPathsExist)
|
||||
{
|
||||
var anyPathsExist = PathMainMenu.paths.Count > 0;
|
||||
AddNewPathToPathsCollection(PathMainMenu.paths, 0);
|
||||
}
|
||||
else if (anyPathsExist && !PathMainMenu.paths.Any(p => p != null && p.State == State.Creating))
|
||||
{
|
||||
AddNewPathToPathsCollection(PathMainMenu.paths, PathMainMenu.paths.IndexOf(PathMainMenu.paths.Where(p => p.State == State.Finished).Last()) + 1);
|
||||
}
|
||||
|
||||
if (!anyPathsExist)
|
||||
{
|
||||
AddNewPathToPathsCollection(PathMainMenu.paths, 0);
|
||||
}
|
||||
else if(anyPathsExist && !PathMainMenu.paths.Any(p => p != null && p.State == State.Creating))
|
||||
{
|
||||
AddNewPathToPathsCollection(PathMainMenu.paths, PathMainMenu.paths.IndexOf(PathMainMenu.paths.Where(p => p.State == State.Finished).Last()) + 1);
|
||||
}
|
||||
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.paths[pathIndex].Waypoints.Count + 1;
|
||||
DrivingFlagType drivingFlag = directWaypointBehavior.Checked ? DrivingFlagType.Direct : DrivingFlagType.Normal;
|
||||
|
||||
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.paths[pathIndex].Waypoints.Count + 1;
|
||||
DrivingFlagType drivingFlag = directWaypointBehavior.Checked ? DrivingFlagType.Direct : DrivingFlagType.Normal;
|
||||
if (collectorWaypoint.Checked)
|
||||
{
|
||||
PathMainMenu.paths[pathIndex].Waypoints.Add(new Waypoint(firstNonNullPath, waypointNumber, waypointPosition, SetDriveSpeedForWaypoint(), drivingFlag, stopWaypointType.Checked, CreateWaypointBlip(), true, collectorRadius.Value, speedZoneRadius.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
PathMainMenu.paths[pathIndex].Waypoints.Add(new Waypoint(firstNonNullPath, waypointNumber, waypointPosition, SetDriveSpeedForWaypoint(), drivingFlag, stopWaypointType.Checked, CreateWaypointBlip()));
|
||||
}
|
||||
Game.LogTrivial($"Path {pathNumber} Waypoint {waypointNumber} added [Driving style: {drivingFlag} | Stop waypoint: {stopWaypointType.Checked} | Speed: {waypointSpeed.Value} | Collector: {collectorWaypoint.Checked}]");
|
||||
|
||||
if (collectorWaypoint.Checked)
|
||||
ToggleTrafficEndPathMenuItem(pathIndex);
|
||||
collectorWaypoint.Enabled = true;
|
||||
collectorWaypoint.Checked = false;
|
||||
if (collectorWaypoint.Checked)
|
||||
{
|
||||
collectorRadius.Enabled = true;
|
||||
speedZoneRadius.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
collectorRadius.Enabled = false;
|
||||
speedZoneRadius.Enabled = false;
|
||||
}
|
||||
trafficRemoveWaypoint.Enabled = true;
|
||||
PathMainMenu.createNewPath.Text = $"Continue Creating Path {pathNumber}";
|
||||
|
||||
float SetDriveSpeedForWaypoint()
|
||||
{
|
||||
float convertedSpeed;
|
||||
if (SettingsMenu.speedUnits.SelectedItem == SpeedUnits.MPH)
|
||||
{
|
||||
PathMainMenu.paths[pathIndex].Waypoints.Add(new Waypoint(firstNonNullPath, waypointNumber, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlag, stopWaypointType.Checked, CreateWaypointBlip(), true, collectorRadius.Value, speedZoneRadius.Value));
|
||||
//Logger.Log($"Original speed: {waypointSpeeds[waypointSpeed.Index]}{SettingsMenu.speedUnits.SelectedItem}");
|
||||
convertedSpeed = MathHelper.ConvertMilesPerHourToMetersPerSecond(waypointSpeed.Value);
|
||||
//Logger.Log($"Converted speed: {convertedSpeed}m/s");
|
||||
}
|
||||
else
|
||||
{
|
||||
PathMainMenu.paths[pathIndex].Waypoints.Add(new Waypoint(firstNonNullPath, waypointNumber, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlag, stopWaypointType.Checked, CreateWaypointBlip()));
|
||||
}
|
||||
Logger.Log($"Path {pathNumber} Waypoint {waypointNumber} added [Driving style: {drivingFlag} | Stop waypoint: {stopWaypointType.Checked} | Speed: {waypointSpeed.Value} | Collector: {collectorWaypoint.Checked}]");
|
||||
|
||||
ToggleTrafficEndPathMenuItem(pathIndex);
|
||||
collectorWaypoint.Enabled = true;
|
||||
collectorWaypoint.Checked = false;
|
||||
trafficRemoveWaypoint.Enabled = true;
|
||||
PathMainMenu.createNewPath.Text = $"Continue Creating Path {pathNumber}";
|
||||
|
||||
float SetDriveSpeedForWaypoint()
|
||||
{
|
||||
float convertedSpeed;
|
||||
if (SettingsMenu.speedUnits.SelectedItem == SpeedUnits.MPH)
|
||||
{
|
||||
//Logger.Log($"Original speed: {waypointSpeeds[waypointSpeed.Index]}{SettingsMenu.speedUnits.SelectedItem}");
|
||||
convertedSpeed = MathHelper.ConvertMilesPerHourToMetersPerSecond(waypointSpeed.Value);
|
||||
//Logger.Log($"Converted speed: {convertedSpeed}m/s");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Logger.Log($"Original speed: {waypointSpeeds[waypointSpeed.Index]}{SettingsMenu.speedUnits.SelectedItem}");
|
||||
convertedSpeed = MathHelper.ConvertKilometersPerHourToMetersPerSecond(waypointSpeed.Value);
|
||||
//Logger.Log($"Converted speed: {convertedSpeed}m/s");
|
||||
}
|
||||
|
||||
return convertedSpeed;
|
||||
//Logger.Log($"Original speed: {waypointSpeeds[waypointSpeed.Index]}{SettingsMenu.speedUnits.SelectedItem}");
|
||||
convertedSpeed = MathHelper.ConvertKilometersPerHourToMetersPerSecond(waypointSpeed.Value);
|
||||
//Logger.Log($"Converted speed: {convertedSpeed}m/s");
|
||||
}
|
||||
|
||||
Blip CreateWaypointBlip()
|
||||
{
|
||||
var spriteNumericalEnum = pathIndex + 17; // 17 because the numerical value of these sprites are always 17 more than the path index
|
||||
var blip = new Blip(Game.LocalPlayer.Character.Position)
|
||||
{
|
||||
Scale = 0.5f,
|
||||
Sprite = (BlipSprite)spriteNumericalEnum
|
||||
};
|
||||
|
||||
if (collectorWaypoint.Checked)
|
||||
{
|
||||
blip.Color = Color.Blue;
|
||||
}
|
||||
else if (stopWaypointType.Checked)
|
||||
{
|
||||
blip.Color = Color.Red;
|
||||
}
|
||||
else
|
||||
{
|
||||
blip.Color = Color.Green;
|
||||
}
|
||||
|
||||
if (!SettingsMenu.mapBlips.Checked)
|
||||
{
|
||||
blip.Alpha = 0f;
|
||||
}
|
||||
|
||||
return blip;
|
||||
}
|
||||
return convertedSpeed;
|
||||
}
|
||||
|
||||
if (selectedItem == trafficRemoveWaypoint)
|
||||
Blip CreateWaypointBlip()
|
||||
{
|
||||
// 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.paths.Count; i++)
|
||||
var spriteNumericalEnum = pathIndex + 17; // 17 because the numerical value of these sprites are always 17 more than the path index
|
||||
var blip = new Blip(waypointPosition)
|
||||
{
|
||||
if (PathMainMenu.paths.ElementAtOrDefault(i) != null && PathMainMenu.paths[i].State == State.Creating)
|
||||
{
|
||||
Logger.Log($"[Path {i + 1}] {PathMainMenu.paths[i].Waypoints.Last().DrivingFlagType} waypoint removed");
|
||||
PathMainMenu.paths[i].Waypoints.Last().Blip.Delete();
|
||||
PathMainMenu.paths[i].Waypoints.Last().RemoveSpeedZone();
|
||||
Scale = 0.5f,
|
||||
Sprite = (BlipSprite)spriteNumericalEnum
|
||||
};
|
||||
|
||||
if (PathMainMenu.paths[i].Waypoints.Last().CollectorRadiusBlip)
|
||||
{
|
||||
PathMainMenu.paths[i].Waypoints.Last().CollectorRadiusBlip.Delete();
|
||||
}
|
||||
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.paths[i].Waypoints.Count == 0)
|
||||
{
|
||||
collectorWaypoint.Checked = true;
|
||||
collectorWaypoint.Enabled = false;
|
||||
speedZoneRadius.Enabled = true;
|
||||
collectorRadius.Enabled = true;
|
||||
trafficRemoveWaypoint.Enabled = false;
|
||||
trafficEndPath.Enabled = false;
|
||||
}
|
||||
}
|
||||
if (collectorWaypoint.Checked)
|
||||
{
|
||||
blip.Color = Color.Blue;
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedItem == trafficEndPath)
|
||||
{
|
||||
// Loop through each path and find the first one which isn't finished
|
||||
for (int i = 0; i < PathMainMenu.paths.Count; i++)
|
||||
else if (stopWaypointType.Checked)
|
||||
{
|
||||
var currentPath = PathMainMenu.paths[i];
|
||||
if (PathMainMenu.paths.ElementAtOrDefault(i) != null && currentPath.State == State.Creating)
|
||||
blip.Color = Color.Red;
|
||||
}
|
||||
else
|
||||
{
|
||||
blip.Color = Color.Green;
|
||||
}
|
||||
|
||||
if (!SettingsMenu.mapBlips.Checked)
|
||||
{
|
||||
blip.Alpha = 0f;
|
||||
}
|
||||
|
||||
return blip;
|
||||
}
|
||||
}
|
||||
|
||||
private static void RemoveWaypoint()
|
||||
{
|
||||
for (int i = 0; i < PathMainMenu.paths.Count; i++)
|
||||
{
|
||||
if (PathMainMenu.paths.ElementAtOrDefault(i) != null && PathMainMenu.paths[i].State == State.Creating)
|
||||
{
|
||||
Game.LogTrivial($"[Path {i + 1}] {PathMainMenu.paths[i].Waypoints.Last().DrivingFlagType} waypoint removed");
|
||||
PathMainMenu.paths[i].Waypoints.Last().Blip.Delete();
|
||||
PathMainMenu.paths[i].Waypoints.Last().RemoveSpeedZone();
|
||||
|
||||
if (PathMainMenu.paths[i].Waypoints.Last().CollectorRadiusBlip)
|
||||
{
|
||||
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.");
|
||||
currentPath.State = State.Finished;
|
||||
currentPath.IsEnabled = true;
|
||||
currentPath.Number = i + 1;
|
||||
currentPath.LoopForVehiclesToBeDismissed();
|
||||
PathMainMenu.paths[i].Waypoints.Last().CollectorRadiusBlip.Delete();
|
||||
}
|
||||
PathMainMenu.paths[i].Waypoints.RemoveAt(PathMainMenu.paths[i].Waypoints.IndexOf(PathMainMenu.paths[i].Waypoints.Last()));
|
||||
|
||||
GameFiber.StartNew(() =>
|
||||
{
|
||||
currentPath.LoopWaypointCollection();
|
||||
//foreach(Waypoint waypoint in PathMainMenu.paths[i].Waypoints)
|
||||
//{
|
||||
// GameFiber WaypointVehicleCollectorFiber = new GameFiber(() => waypoint.CollectVehicles(PathMainMenu.paths));
|
||||
// WaypointVehicleCollectorFiber.Start();
|
||||
// GameFiber.Sleep(1000);
|
||||
//}
|
||||
});
|
||||
ToggleTrafficEndPathMenuItem(i);
|
||||
|
||||
PathMainMenu.createNewPath.Text = "Create New Path";
|
||||
PathMainMenu.BuildPathMenu();
|
||||
PathMainMenu.pathMainMenu.RefreshIndex();
|
||||
pathCreationMenu.RefreshIndex();
|
||||
waypointSpeed.Index = 0;
|
||||
collectorWaypoint.Enabled = false;
|
||||
// If the path has no waypoints, disable the menu option to remove a waypoint
|
||||
if (PathMainMenu.paths[i].Waypoints.Count == 0)
|
||||
{
|
||||
collectorWaypoint.Checked = true;
|
||||
collectorWaypoint.Enabled = false;
|
||||
speedZoneRadius.Enabled = true;
|
||||
speedZoneRadius.Index = 0;
|
||||
collectorRadius.Enabled = true;
|
||||
collectorRadius.Index = 0;
|
||||
stopWaypointType.Checked = false;
|
||||
directWaypointBehavior.Checked = false;
|
||||
trafficRemoveWaypoint.Enabled = false;
|
||||
trafficEndPath.Enabled = false;
|
||||
PathMainMenu.pathMainMenu.Visible = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void PathCreation_OnScrollerChanged(UIMenu sender, UIMenuScrollerItem scrollerItem, int first, int last)
|
||||
private static void EndPath()
|
||||
{
|
||||
if (scrollerItem == collectorRadius)
|
||||
for (int i = 0; i < PathMainMenu.paths.Count; i++)
|
||||
{
|
||||
if (collectorRadius.Value > speedZoneRadius.Value)
|
||||
var currentPath = PathMainMenu.paths[i];
|
||||
if (PathMainMenu.paths.ElementAtOrDefault(i) != null && currentPath.State == State.Creating)
|
||||
{
|
||||
while(collectorRadius.Value > speedZoneRadius.Value)
|
||||
{
|
||||
speedZoneRadius.ScrollToNextOption();
|
||||
}
|
||||
}
|
||||
}
|
||||
Game.LogTrivial($"[Path Creation] Path {currentPath.Number} finished with {currentPath.Waypoints.Count} waypoints.");
|
||||
Game.DisplayNotification($"~o~Scene Manager ~g~[Success]\n~w~Path {i + 1} complete.");
|
||||
currentPath.State = State.Finished;
|
||||
currentPath.IsEnabled = true;
|
||||
currentPath.Number = i + 1;
|
||||
currentPath.LoopForVehiclesToBeDismissed();
|
||||
|
||||
if(scrollerItem == speedZoneRadius)
|
||||
{
|
||||
if(speedZoneRadius.Value < collectorRadius.Value)
|
||||
{
|
||||
collectorRadius.Value = speedZoneRadius.Value;
|
||||
GameFiber.StartNew(() =>
|
||||
{
|
||||
currentPath.LoopWaypointCollection();
|
||||
});
|
||||
|
||||
PathMainMenu.createNewPath.Text = "Create New Path";
|
||||
PathMainMenu.BuildPathMenu();
|
||||
PathMainMenu.pathMainMenu.RefreshIndex();
|
||||
pathCreationMenu.Clear();
|
||||
PathMainMenu.pathMainMenu.Visible = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -276,14 +251,82 @@ namespace SceneManager
|
|||
}
|
||||
}
|
||||
|
||||
internal static void AddNewPathToPathsCollection(List<Path> paths, int pathIndex)
|
||||
private static void AddNewPathToPathsCollection(List<Path> paths, int pathIndex)
|
||||
{
|
||||
var pathNum = pathIndex + 1;
|
||||
Logger.Log($"Creating path {pathNum}");
|
||||
Game.LogTrivial($"Creating path {pathNum}");
|
||||
Game.DisplayNotification($"~o~Scene Manager\n~y~[Creating]~w~ Path {pathNum} started.");
|
||||
paths.Insert(pathIndex, new Path(pathNum, State.Creating));
|
||||
trafficRemoveWaypoint.Enabled = false;
|
||||
trafficEndPath.Enabled = false;
|
||||
}
|
||||
|
||||
private static void PathCreation_OnCheckboxChanged(UIMenu sender, UIMenuCheckboxItem checkboxItem, bool @checked)
|
||||
{
|
||||
if(checkboxItem == collectorWaypoint)
|
||||
{
|
||||
collectorRadius.Enabled = collectorWaypoint.Checked ? true : false;
|
||||
speedZoneRadius.Enabled = collectorWaypoint.Checked ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void PathCreation_OnItemSelected(UIMenu sender, UIMenuItem selectedItem, int index)
|
||||
{
|
||||
if (selectedItem == trafficAddWaypoint)
|
||||
{
|
||||
AddNewWaypoint();
|
||||
}
|
||||
|
||||
if (selectedItem == trafficRemoveWaypoint)
|
||||
{
|
||||
RemoveWaypoint();
|
||||
}
|
||||
|
||||
if (selectedItem == trafficEndPath)
|
||||
{
|
||||
EndPath();
|
||||
}
|
||||
}
|
||||
|
||||
private static void PathCreation_OnScrollerChanged(UIMenu sender, UIMenuScrollerItem scrollerItem, int first, int last)
|
||||
{
|
||||
if (scrollerItem == collectorRadius)
|
||||
{
|
||||
if (collectorRadius.Value > speedZoneRadius.Value)
|
||||
{
|
||||
while (collectorRadius.Value > speedZoneRadius.Value)
|
||||
{
|
||||
speedZoneRadius.ScrollToNextOption();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (scrollerItem == speedZoneRadius)
|
||||
{
|
||||
if (speedZoneRadius.Value < collectorRadius.Value)
|
||||
{
|
||||
collectorRadius.Value = speedZoneRadius.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void PathCreation_OnMenuOpen(UIMenu menu)
|
||||
{
|
||||
var scrollerItems = new List<UIMenuScrollerItem> { collectorRadius, speedZoneRadius, waypointSpeed };
|
||||
var checkboxItems = new Dictionary<UIMenuCheckboxItem, RNUIMouseInputHandler.Function>()
|
||||
{
|
||||
{ collectorWaypoint, UpdateCollectorMenuOptionsStatus},
|
||||
{ stopWaypointType, null},
|
||||
{ directWaypointBehavior, null}
|
||||
};
|
||||
var selectItems = new Dictionary<UIMenuItem, RNUIMouseInputHandler.Function>()
|
||||
{
|
||||
{ trafficAddWaypoint, AddNewWaypoint },
|
||||
{ trafficRemoveWaypoint, RemoveWaypoint },
|
||||
{ trafficEndPath, EndPath }
|
||||
};
|
||||
|
||||
RNUIMouseInputHandler.Initialize(menu, scrollerItems, checkboxItems, selectItems);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue