mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 07:30:40 +01:00
Moved to new namespace
This commit is contained in:
parent
bcaecb8788
commit
1e50d1f537
12 changed files with 366 additions and 439 deletions
266
SceneManager/Managers/BarrierManager.cs
Normal file
266
SceneManager/Managers/BarrierManager.cs
Normal file
|
|
@ -0,0 +1,266 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Rage;
|
||||
using SceneManager.Barriers;
|
||||
using SceneManager.Menus;
|
||||
using SceneManager.Paths;
|
||||
using SceneManager.Utils;
|
||||
|
||||
namespace SceneManager.Managers
|
||||
{
|
||||
internal static class BarrierManager
|
||||
{
|
||||
internal static Object PlaceholderBarrier { get; private set; }
|
||||
internal static List<Barrier> Barriers { get; } = new List<Barrier>();
|
||||
|
||||
internal static void CreatePlaceholderBarrier()
|
||||
{
|
||||
Hints.Display($"~o~Scene Manager ~y~[Hint]\n~w~The shadow barrier will disappear if you aim too far away.");
|
||||
if (PlaceholderBarrier)
|
||||
{
|
||||
PlaceholderBarrier.Delete();
|
||||
}
|
||||
|
||||
var barrierKey = Settings.Barriers.Where(x => x.Key == BarrierMenu.BarrierList.SelectedItem).FirstOrDefault().Key;
|
||||
var barrierValue = Settings.Barriers[barrierKey].Name;
|
||||
PlaceholderBarrier = new Object(barrierValue, UserInput.PlayerMousePositionForBarrier, BarrierMenu.RotateBarrier.Value);
|
||||
if (!PlaceholderBarrier)
|
||||
{
|
||||
BarrierMenu.Menu.Close();
|
||||
Game.LogTrivial($"Something went wrong creating the placeholder barrier. Mouse position: {UserInput.PlayerMousePositionForBarrier}");
|
||||
Game.DisplayNotification($"~o~Scene Manager ~r~[Error]\n~w~Something went wrong creating the placeholder barrier. This is a rare problem that only happens in certain areas of the world. Please try again somewhere else.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Rage.Native.NativeFunction.Natives.SET_ENTITY_TRAFFICLIGHT_OVERRIDE(shadowBarrier, setBarrierTrafficLight.Index);
|
||||
Rage.Native.NativeFunction.Natives.PLACE_OBJECT_ON_GROUND_PROPERLY(PlaceholderBarrier);
|
||||
PlaceholderBarrier.IsGravityDisabled = true;
|
||||
PlaceholderBarrier.IsCollisionEnabled = false;
|
||||
PlaceholderBarrier.Opacity = 0.7f;
|
||||
|
||||
// Start with lights off for Parks's objects
|
||||
if (Settings.EnableAdvancedBarricadeOptions)
|
||||
{
|
||||
Rage.Native.NativeFunction.Natives.x971DA0055324D033(PlaceholderBarrier, BarrierMenu.BarrierTexture.Value); // _SET_OBJECT_TEXTURE_VARIATION
|
||||
SetBarrierLights();
|
||||
}
|
||||
}
|
||||
|
||||
internal static void SetBarrierLights()
|
||||
{
|
||||
if (BarrierMenu.SetBarrierLights.Checked)
|
||||
{
|
||||
Rage.Native.NativeFunction.Natives.SET_ENTITY_LIGHTS(PlaceholderBarrier, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Rage.Native.NativeFunction.Natives.SET_ENTITY_LIGHTS(PlaceholderBarrier, true);
|
||||
}
|
||||
|
||||
//Rage.Native.NativeFunction.Natives.SET_ENTITY_TRAFFICLIGHT_OVERRIDE(shadowBarrier, setBarrierTrafficLight.Index);
|
||||
}
|
||||
|
||||
internal static void UpdatePlaceholderBarrierPosition()
|
||||
{
|
||||
DisableBarrierMenuOptionsIfShadowConeTooFar();
|
||||
if (PlaceholderBarrier)
|
||||
{
|
||||
PlaceholderBarrier.Heading = BarrierMenu.RotateBarrier.Value;
|
||||
PlaceholderBarrier.Position = UserInput.PlayerMousePositionForBarrier;
|
||||
Rage.Native.NativeFunction.Natives.PLACE_OBJECT_ON_GROUND_PROPERLY(PlaceholderBarrier);
|
||||
//Rage.Native.NativeFunction.Natives.SET_ENTITY_TRAFFICLIGHT_OVERRIDE(shadowBarrier, setBarrierTrafficLight.Index);
|
||||
}
|
||||
|
||||
void DisableBarrierMenuOptionsIfShadowConeTooFar()
|
||||
{
|
||||
if (!PlaceholderBarrier && UserInput.PlayerMousePositionForBarrier.DistanceTo2D(Game.LocalPlayer.Character.Position) <= Settings.BarrierPlacementDistance)
|
||||
{
|
||||
CreatePlaceholderBarrier();
|
||||
|
||||
}
|
||||
else if (PlaceholderBarrier && PlaceholderBarrier.Position.DistanceTo2D(Game.LocalPlayer.Character.Position) > Settings.BarrierPlacementDistance)
|
||||
{
|
||||
BarrierMenu.BarrierList.Enabled = false;
|
||||
BarrierMenu.RotateBarrier.Enabled = false;
|
||||
PlaceholderBarrier.Delete();
|
||||
}
|
||||
else if (PlaceholderBarrier && PlaceholderBarrier.Position.DistanceTo2D(Game.LocalPlayer.Character.Position) <= Settings.BarrierPlacementDistance && BarrierMenu.BarrierList.SelectedItem == "Flare")
|
||||
{
|
||||
BarrierMenu.BarrierList.Enabled = true;
|
||||
BarrierMenu.RotateBarrier.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
BarrierMenu.BarrierList.Enabled = true;
|
||||
BarrierMenu.RotateBarrier.Enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static void LoopToRenderPlaceholderBarrier()
|
||||
{
|
||||
while (BarrierMenu.Menu.Visible)
|
||||
{
|
||||
if (BarrierMenu.BarrierList.Selected || BarrierMenu.RotateBarrier.Selected || BarrierMenu.Invincible.Selected || BarrierMenu.Immobile.Selected || BarrierMenu.BarrierTexture.Selected || BarrierMenu.SetBarrierLights.Selected || BarrierMenu.SetBarrierTrafficLight.Selected)
|
||||
{
|
||||
if (PlaceholderBarrier)
|
||||
{
|
||||
//UpdatePlaceholderBarrierPosition();
|
||||
UpdatePlaceholderBarrierPosition();
|
||||
}
|
||||
else if (UserInput.PlayerMousePositionForBarrier.DistanceTo2D(Game.LocalPlayer.Character.Position) <= Settings.BarrierPlacementDistance)
|
||||
{
|
||||
//CreatePlaceholderBarrier();
|
||||
CreatePlaceholderBarrier();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PlaceholderBarrier)
|
||||
{
|
||||
PlaceholderBarrier.Delete();
|
||||
}
|
||||
}
|
||||
GameFiber.Yield();
|
||||
}
|
||||
|
||||
if (PlaceholderBarrier)
|
||||
{
|
||||
PlaceholderBarrier.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
internal static void SpawnBarrier()
|
||||
{
|
||||
Barrier barrier;
|
||||
|
||||
if (BarrierMenu.BarrierList.SelectedItem == "Flare")
|
||||
{
|
||||
SpawnFlare();
|
||||
}
|
||||
else
|
||||
{
|
||||
//var obj = new Object(PlaceholderBarrier.Model, PlaceholderBarrier.Position, BarrierMenu.RotateBarrier.Value);
|
||||
barrier = new Barrier(PlaceholderBarrier.Model.Name, PlaceholderBarrier.Position, PlaceholderBarrier.Heading, BarrierMenu.Invincible.Checked, BarrierMenu.Immobile.Checked, BarrierMenu.BarrierTexture.Value, BarrierMenu.SetBarrierLights.Checked);
|
||||
Barriers.Add(barrier);
|
||||
|
||||
BarrierMenu.RemoveBarrierOptions.Enabled = true;
|
||||
BarrierMenu.ResetBarriers.Enabled = true;
|
||||
}
|
||||
|
||||
if (barrier != null && BarrierMenu.BelongsToPath.Checked)
|
||||
{
|
||||
var matchingPath = PathManager.Paths.FirstOrDefault(x => x.Name == BarrierMenu.AddToPath.OptionText);
|
||||
if(matchingPath != null)
|
||||
{
|
||||
matchingPath.Barriers.Add(barrier);
|
||||
}
|
||||
}
|
||||
|
||||
void SpawnFlare()
|
||||
{
|
||||
var flare = new Weapon("weapon_flare", PlaceholderBarrier.Position, 1);
|
||||
Rage.Native.NativeFunction.Natives.SET_ENTITY_DYNAMIC(flare, true);
|
||||
GameFiber.Sleep(1);
|
||||
GameFiber.StartNew(() =>
|
||||
{
|
||||
while (flare && flare.HeightAboveGround > 0.05f)
|
||||
{
|
||||
GameFiber.Yield();
|
||||
}
|
||||
GameFiber.Sleep(1000);
|
||||
if (flare)
|
||||
{
|
||||
flare.IsPositionFrozen = true;
|
||||
}
|
||||
}, "Spawn Flare Fiber");
|
||||
|
||||
//var obj = new Object(flare.Model, flare.Position, flare.Heading);
|
||||
barrier = new Barrier(flare.Model.Name, flare.Position, flare.Heading, BarrierMenu.Invincible.Checked, BarrierMenu.Immobile.Checked);
|
||||
Barriers.Add(barrier);
|
||||
BarrierMenu.RemoveBarrierOptions.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal static void RemoveBarrier(int removeBarrierOptionsIndex)
|
||||
{
|
||||
Path path;
|
||||
switch (removeBarrierOptionsIndex)
|
||||
{
|
||||
case 0:
|
||||
var barrierToRemove = Barriers[Barriers.Count - 1];
|
||||
path = PathManager.Paths.FirstOrDefault(x => x.Barriers.Contains(barrierToRemove));
|
||||
if(path != null)
|
||||
{
|
||||
path.Barriers.Remove(barrierToRemove);
|
||||
}
|
||||
|
||||
barrierToRemove.Delete();
|
||||
Barriers.RemoveAt(Barriers.Count - 1);
|
||||
break;
|
||||
case 1:
|
||||
var nearestBarrier = Barriers.OrderBy(b => b.DistanceTo2D(Game.LocalPlayer.Character)).FirstOrDefault();
|
||||
if (nearestBarrier != null)
|
||||
{
|
||||
path = PathManager.Paths.FirstOrDefault(x => x.Barriers.Contains(nearestBarrier));
|
||||
if (path != null)
|
||||
{
|
||||
path.Barriers.Remove(nearestBarrier);
|
||||
}
|
||||
|
||||
nearestBarrier.Delete();
|
||||
Barriers.Remove(nearestBarrier);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
foreach (Barrier barrier in Barriers)
|
||||
{
|
||||
path = PathManager.Paths.FirstOrDefault(x => x.Barriers.Contains(barrier));
|
||||
if (path != null)
|
||||
{
|
||||
path.Barriers.Remove(barrier);
|
||||
}
|
||||
|
||||
barrier.Delete();
|
||||
}
|
||||
if (Barriers.Count > 0)
|
||||
{
|
||||
Barriers.Clear();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
BarrierMenu.RemoveBarrierOptions.Enabled = Barriers.Count != 0;
|
||||
BarrierMenu.ResetBarriers.Enabled = Barriers.Count != 0;
|
||||
}
|
||||
|
||||
internal static void ResetBarriers()
|
||||
{
|
||||
GameFiber.StartNew(() =>
|
||||
{
|
||||
var currentBarriers = Barriers.Where(b => b.ModelName != "0xa2c44e80").ToList(); // 0xa2c44e80 is the flare weapon hash
|
||||
foreach (Barrier barrier in currentBarriers)
|
||||
{
|
||||
//var obj = new Object(barrier.ModelName, barrier.Position, barrier.Heading);
|
||||
var newBarrier = new Barrier(barrier.ModelName, barrier.Position, barrier.Heading, barrier.Invincible, barrier.Immobile, barrier.TextureVariation, barrier.LightsEnabled);
|
||||
Barriers.Add(newBarrier);
|
||||
|
||||
if (barrier.IsValid())
|
||||
{
|
||||
barrier.Delete();
|
||||
}
|
||||
Barriers.Remove(barrier);
|
||||
}
|
||||
currentBarriers.Clear();
|
||||
}, "Barrier Reset Fiber");
|
||||
|
||||
}
|
||||
|
||||
internal static void RotateBarrier()
|
||||
{
|
||||
PlaceholderBarrier.Heading = BarrierMenu.RotateBarrier.Value;
|
||||
PlaceholderBarrier.Position = UserInput.PlayerMousePositionForBarrier;
|
||||
Rage.Native.NativeFunction.Natives.PLACE_OBJECT_ON_GROUND_PROPERLY(PlaceholderBarrier);
|
||||
}
|
||||
}
|
||||
}
|
||||
79
SceneManager/Managers/MenuManager.cs
Normal file
79
SceneManager/Managers/MenuManager.cs
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
using RAGENativeUI;
|
||||
using SceneManager.Menus;
|
||||
using Rage;
|
||||
using System.Linq;
|
||||
using RAGENativeUI.Elements;
|
||||
using System.Drawing;
|
||||
|
||||
namespace SceneManager.Managers
|
||||
{
|
||||
// The only reason this class should change is to modify how menus are are being handled
|
||||
internal static class MenuManager
|
||||
{
|
||||
internal static MenuPool MenuPool { get; } = new MenuPool();
|
||||
|
||||
internal static void InitializeMenus()
|
||||
{
|
||||
MainMenu.Initialize();
|
||||
SettingsMenu.Initialize();
|
||||
PathMainMenu.Initialize();
|
||||
PathCreationMenu.Initialize();
|
||||
ImportPathMenu.Initialize();
|
||||
DriverMenu.Initialize();
|
||||
BarrierMenu.Initialize();
|
||||
EditPathMenu.Initialize();
|
||||
EditWaypointMenu.Initialize();
|
||||
|
||||
BuildMenus();
|
||||
ColorMenuItems();
|
||||
DefineMenuMouseSettings();
|
||||
}
|
||||
|
||||
private static void DefineMenuMouseSettings()
|
||||
{
|
||||
foreach (UIMenu menu in MenuPool)
|
||||
{
|
||||
menu.MouseControlsEnabled = false;
|
||||
menu.AllowCameraMovement = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal static void BuildMenus()
|
||||
{
|
||||
MainMenu.BuildMainMenu();
|
||||
SettingsMenu.BuildSettingsMenu();
|
||||
DriverMenu.Build();
|
||||
PathMainMenu.Build();
|
||||
PathCreationMenu.BuildPathCreationMenu();
|
||||
ImportPathMenu.BuildImportMenu();
|
||||
EditPathMenu.BuildEditPathMenu();
|
||||
BarrierMenu.BuildMenu();
|
||||
}
|
||||
|
||||
internal static void ColorMenuItems()
|
||||
{
|
||||
foreach(UIMenuItem menuItem in MenuPool.SelectMany(x => x.MenuItems))
|
||||
{
|
||||
if (menuItem.Enabled)
|
||||
{
|
||||
menuItem.HighlightedBackColor = menuItem.ForeColor;
|
||||
}
|
||||
if(!menuItem.Enabled)
|
||||
{
|
||||
menuItem.HighlightedBackColor = Color.DarkGray;
|
||||
menuItem.DisabledForeColor = Color.Gray;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static void ProcessMenus()
|
||||
{
|
||||
while (MenuPool.Any(x => x.Visible))
|
||||
{
|
||||
MenuPool.ProcessMenus();
|
||||
ColorMenuItems();
|
||||
GameFiber.Yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
280
SceneManager/Managers/PathManager.cs
Normal file
280
SceneManager/Managers/PathManager.cs
Normal file
|
|
@ -0,0 +1,280 @@
|
|||
using Rage;
|
||||
using SceneManager.Menus;
|
||||
using SceneManager.Paths;
|
||||
using SceneManager.Utils;
|
||||
using SceneManager.Waypoints;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace SceneManager.Managers
|
||||
{
|
||||
internal class PathManager
|
||||
{
|
||||
internal static List<Path> Paths { get; } = new List<Path>(10);
|
||||
|
||||
internal static Path ImportPath(Path importedPath)
|
||||
{
|
||||
importedPath.State = State.Creating;
|
||||
|
||||
var firstVacantIndex = Paths.IndexOf(Paths.FirstOrDefault(x => x.State == State.Uninitialized)) + 1; // != State.Creating
|
||||
if (firstVacantIndex < 0)
|
||||
{
|
||||
firstVacantIndex = 0;
|
||||
}
|
||||
var pathNumber = firstVacantIndex + 1;
|
||||
|
||||
importedPath.Number = pathNumber;
|
||||
Paths.Insert(firstVacantIndex, importedPath);
|
||||
|
||||
Game.LogTrivial($"Importing path {importedPath.Number} at Paths index {firstVacantIndex}");
|
||||
Game.DisplayNotification($"~o~Scene Manager ~y~[Importing]\n~w~Path {importedPath.Number} import started.");
|
||||
|
||||
return importedPath;
|
||||
}
|
||||
|
||||
internal static void ExportPath()
|
||||
{
|
||||
var currentPath = Paths[PathMainMenu.EditPath.Index];
|
||||
// Reference PNWParks's UserInput class from LiveLights
|
||||
var filename = UserInput.PromptPlayerForFileName("Type the name you would like to save your file as", "Enter a filename", 100) + ".xml";
|
||||
|
||||
// If filename != null or empty, check if export directory exists (GTA V/Plugins/SceneManager/Saved Paths)
|
||||
if (string.IsNullOrWhiteSpace(filename))
|
||||
{
|
||||
Game.DisplayHelp($"Invalid filename given. Filename cannot be null, empty, or consist of just white spaces.");
|
||||
Game.LogTrivial($"Invalid filename given. Filename cannot be null, empty, or consist of just white spaces.");
|
||||
return;
|
||||
}
|
||||
Game.LogTrivial($"Filename: {filename}");
|
||||
currentPath.Save(filename);
|
||||
currentPath.Name = filename.Remove(filename.Length - 4);
|
||||
Game.LogTrivial($"Path name: {currentPath.Name}");
|
||||
Game.LogTrivial($"Exporting path {currentPath.Number}");
|
||||
Game.DisplayNotification($"~o~Scene Manager ~y~[Exporting]\n~w~Path {currentPath.Number} exported.");
|
||||
Settings.ImportPaths();
|
||||
PathMainMenu.ImportPath.Enabled = true;
|
||||
ImportPathMenu.BuildImportMenu();
|
||||
PathMainMenu.Build();
|
||||
|
||||
PathMainMenu.Menu.Visible = true;
|
||||
}
|
||||
|
||||
internal static Path InitializeNewPath()
|
||||
{
|
||||
PathCreationMenu.PathCreationState = State.Creating;
|
||||
|
||||
var firstVacantIndex = Paths.IndexOf(Paths.FirstOrDefault(x => x.State != State.Creating)) + 1;
|
||||
if(firstVacantIndex < 0)
|
||||
{
|
||||
firstVacantIndex = 0;
|
||||
}
|
||||
var pathNumber = firstVacantIndex + 1;
|
||||
|
||||
Path newPath = new Path(pathNumber, State.Creating);
|
||||
Paths.Insert(firstVacantIndex, newPath);
|
||||
|
||||
Game.LogTrivial($"Creating path {newPath.Number} at Paths index {firstVacantIndex}");
|
||||
Game.DisplayNotification($"~o~Scene Manager ~y~[Creating]\n~w~Path {newPath.Number} started.");
|
||||
|
||||
PathCreationMenu.RemoveLastWaypoint.Enabled = false;
|
||||
PathCreationMenu.EndPathCreation.Enabled = false;
|
||||
|
||||
return newPath;
|
||||
}
|
||||
|
||||
internal static void AddWaypoint(Path currentPath)
|
||||
{
|
||||
var waypointNumber = currentPath.Waypoints.Count + 1;
|
||||
DrivingFlagType drivingFlag = PathCreationMenu.DirectWaypoint.Checked ? DrivingFlagType.Direct : DrivingFlagType.Normal;
|
||||
Waypoint newWaypoint;
|
||||
if (PathCreationMenu.CollectorWaypoint.Checked)
|
||||
{
|
||||
newWaypoint = new Waypoint(currentPath, waypointNumber, UserInput.PlayerMousePosition, ConvertDriveSpeedForWaypoint(PathCreationMenu.WaypointSpeed.Value), drivingFlag, PathCreationMenu.StopWaypoint.Checked, true, PathCreationMenu.CollectorRadius.Value, PathCreationMenu.SpeedZoneRadius.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
newWaypoint = new Waypoint(currentPath, waypointNumber, UserInput.PlayerMousePosition, ConvertDriveSpeedForWaypoint(PathCreationMenu.WaypointSpeed.Value), drivingFlag, PathCreationMenu.StopWaypoint.Checked);
|
||||
}
|
||||
currentPath.Waypoints.Add(newWaypoint);
|
||||
Game.LogTrivial($"Path {currentPath.Number} Waypoint {waypointNumber} added [Driving style: {drivingFlag} | Stop waypoint: {newWaypoint.IsStopWaypoint} | Speed: {newWaypoint.Speed} | Collector: {newWaypoint.IsCollector}]");
|
||||
|
||||
if(currentPath.Waypoints.Count == 1)
|
||||
{
|
||||
PathMainMenu.CreateNewPath.Text = $"Continue Creating Path {currentPath.Number}";
|
||||
}
|
||||
}
|
||||
|
||||
internal static void AddNewEditWaypoint(Path currentPath)
|
||||
{
|
||||
DrivingFlagType drivingFlag = EditWaypointMenu.DirectWaypointBehavior.Checked ? DrivingFlagType.Direct : DrivingFlagType.Normal;
|
||||
|
||||
if (EditWaypointMenu.CollectorWaypoint.Checked)
|
||||
{
|
||||
currentPath.Waypoints.Add(new Waypoint(currentPath, currentPath.Waypoints.Last().Number + 1, UserInput.PlayerMousePosition, ConvertDriveSpeedForWaypoint(EditWaypointMenu.ChangeWaypointSpeed.Value), drivingFlag, EditWaypointMenu.StopWaypointType.Checked, true, EditWaypointMenu.ChangeCollectorRadius.Value, EditWaypointMenu.ChangeSpeedZoneRadius.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
currentPath.Waypoints.Add(new Waypoint(currentPath, currentPath.Waypoints.Last().Number + 1, UserInput.PlayerMousePosition, ConvertDriveSpeedForWaypoint(EditWaypointMenu.ChangeWaypointSpeed.Value), drivingFlag, EditWaypointMenu.StopWaypointType.Checked));
|
||||
}
|
||||
Game.LogTrivial($"New waypoint (#{currentPath.Waypoints.Last().Number}) added.");
|
||||
}
|
||||
|
||||
internal static void UpdateWaypoint()
|
||||
{
|
||||
//var currentPath = Paths[PathMainMenu.EditPath.Index];
|
||||
var currentPath = Paths.FirstOrDefault(x => x.Name == PathMainMenu.EditPath.OptionText);
|
||||
var currentWaypoint = currentPath.Waypoints[EditWaypointMenu.EditWaypoint.Index];
|
||||
DrivingFlagType drivingFlag = EditWaypointMenu.DirectWaypointBehavior.Checked ? DrivingFlagType.Direct : DrivingFlagType.Normal;
|
||||
|
||||
if (currentPath.Waypoints.Count == 1)
|
||||
{
|
||||
currentWaypoint.UpdateWaypoint(currentWaypoint, UserInput.PlayerMousePosition, drivingFlag, EditWaypointMenu.StopWaypointType.Checked, ConvertDriveSpeedForWaypoint(EditWaypointMenu.ChangeWaypointSpeed.Value), true, EditWaypointMenu.ChangeCollectorRadius.Value, EditWaypointMenu.ChangeSpeedZoneRadius.Value, EditWaypointMenu.UpdateWaypointPosition.Checked);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentWaypoint.UpdateWaypoint(currentWaypoint, UserInput.PlayerMousePosition, drivingFlag, EditWaypointMenu.StopWaypointType.Checked, ConvertDriveSpeedForWaypoint(EditWaypointMenu.ChangeWaypointSpeed.Value), EditWaypointMenu.CollectorWaypoint.Checked, EditWaypointMenu.ChangeCollectorRadius.Value, EditWaypointMenu.ChangeSpeedZoneRadius.Value, EditWaypointMenu.UpdateWaypointPosition.Checked);
|
||||
}
|
||||
Game.LogTrivial($"Path {currentPath.Number} Waypoint {currentWaypoint.Number} updated [Driving style: {drivingFlag} | Stop waypoint: {EditWaypointMenu.StopWaypointType.Checked} | Speed: {EditWaypointMenu.ChangeWaypointSpeed.Value} | Collector: {currentWaypoint.IsCollector}]");
|
||||
|
||||
EditWaypointMenu.UpdateWaypointPosition.Checked = false;
|
||||
Game.DisplayNotification($"~o~Scene Manager ~g~[Success]~w~\nWaypoint {currentWaypoint.Number} updated.");
|
||||
}
|
||||
|
||||
private static float ConvertDriveSpeedForWaypoint(float speed)
|
||||
{
|
||||
float convertedSpeed = SettingsMenu.SpeedUnits.SelectedItem == SpeedUnits.MPH
|
||||
? MathHelper.ConvertMilesPerHourToMetersPerSecond(speed)
|
||||
: MathHelper.ConvertKilometersPerHourToMetersPerSecond(speed);
|
||||
return convertedSpeed;
|
||||
}
|
||||
|
||||
internal static void RemoveWaypoint(Path currentPath)
|
||||
{
|
||||
Waypoint lastWaypoint = currentPath.Waypoints.Last();
|
||||
lastWaypoint.Delete();
|
||||
currentPath.Waypoints.Remove(lastWaypoint);
|
||||
}
|
||||
|
||||
internal static void RemoveEditWaypoint(Path currentPath)
|
||||
{
|
||||
var currentWaypoint = currentPath.Waypoints[EditWaypointMenu.EditWaypoint.Index];
|
||||
if (currentPath.Waypoints.Count == 1)
|
||||
{
|
||||
Game.LogTrivial($"Deleting the last waypoint from the path.");
|
||||
currentPath.Delete();
|
||||
Paths.Remove(currentPath);
|
||||
PathMainMenu.Build();
|
||||
|
||||
EditWaypointMenu.Menu.Visible = false;
|
||||
PathMainMenu.Menu.Visible = true;
|
||||
return;
|
||||
}
|
||||
|
||||
currentWaypoint.Delete();
|
||||
currentPath.Waypoints.Remove(currentWaypoint);
|
||||
Game.LogTrivial($"[Path {currentPath.Number}] Waypoint {currentWaypoint.Number} ({currentWaypoint.DrivingFlagType}) removed");
|
||||
currentPath.Waypoints.ForEach(x => x.Number = currentPath.Waypoints.IndexOf(x) + 1);
|
||||
|
||||
DefaultWaypointToCollector(currentPath);
|
||||
}
|
||||
|
||||
private static void DefaultWaypointToCollector(Path currentPath)
|
||||
{
|
||||
if (currentPath.Waypoints.Count == 1)
|
||||
{
|
||||
DrivingFlagType drivingFlag = EditWaypointMenu.DirectWaypointBehavior.Checked ? DrivingFlagType.Direct : DrivingFlagType.Normal;
|
||||
Hints.Display($"~o~Scene Manager ~y~[Hint]~w~\nYour path's first waypoint ~b~must~w~ be a collector. If it's not, it will automatically be made into one.");
|
||||
Game.LogTrivial($"The path only has 1 waypoint left, this waypoint must be a collector.");
|
||||
currentPath.Waypoints[0].UpdateWaypoint(currentPath.Waypoints.First(), UserInput.PlayerMousePosition, drivingFlag, EditWaypointMenu.StopWaypointType.Checked, ConvertDriveSpeedForWaypoint(EditWaypointMenu.ChangeWaypointSpeed.Value), true, EditWaypointMenu.ChangeCollectorRadius.Value, EditWaypointMenu.ChangeSpeedZoneRadius.Value, EditWaypointMenu.UpdateWaypointPosition.Checked);
|
||||
EditWaypointMenu.CollectorWaypoint.Checked = true;
|
||||
EditWaypointMenu.ChangeCollectorRadius.Enabled = true;
|
||||
EditWaypointMenu.ChangeSpeedZoneRadius.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal static void EndPath(Path currentPath)
|
||||
{
|
||||
Game.LogTrivial($"[Path Creation] Path {currentPath.Number} finished with {currentPath.Waypoints.Count} waypoints.");
|
||||
Game.DisplayNotification($"~o~Scene Manager ~g~[Success]\n~w~Path {currentPath.Number} complete.");
|
||||
currentPath.State = State.Finished;
|
||||
currentPath.IsEnabled = true;
|
||||
currentPath.Waypoints.ForEach(x => x.EnableBlip());
|
||||
GameFiber.StartNew(() => currentPath.LoopForVehiclesToBeDismissed(), "Vehicle Cleanup Loop Fiber");
|
||||
GameFiber.StartNew(() => currentPath.LoopWaypointCollection(), "Waypoint Collection Loop Fiber");
|
||||
|
||||
PathMainMenu.CreateNewPath.Text = "Create New Path";
|
||||
PathMainMenu.Build();
|
||||
PathMainMenu.Menu.Visible = true;
|
||||
|
||||
MainMenu.BuildMainMenu();
|
||||
DriverMenu.Build();
|
||||
PathCreationMenu.BuildPathCreationMenu();
|
||||
BarrierMenu.BuildMenu();
|
||||
}
|
||||
|
||||
internal static void TogglePathCreationMenuItems(Path currentPath)
|
||||
{
|
||||
if(currentPath.Waypoints.Count == 1)
|
||||
{
|
||||
PathCreationMenu.CollectorWaypoint.Enabled = true;
|
||||
PathCreationMenu.CollectorWaypoint.Checked = false;
|
||||
PathCreationMenu.RemoveLastWaypoint.Enabled = true;
|
||||
PathCreationMenu.EndPathCreation.Enabled = true;
|
||||
}
|
||||
|
||||
if (currentPath.Waypoints.Count < 1)
|
||||
{
|
||||
PathCreationMenu.CollectorWaypoint.Enabled = false;
|
||||
PathCreationMenu.CollectorWaypoint.Checked = true;
|
||||
PathCreationMenu.RemoveLastWaypoint.Enabled = false;
|
||||
PathCreationMenu.EndPathCreation.Enabled = false;
|
||||
}
|
||||
|
||||
if (PathCreationMenu.CollectorWaypoint.Checked)
|
||||
{
|
||||
PathCreationMenu.CollectorRadius.Enabled = true;
|
||||
PathCreationMenu.SpeedZoneRadius.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PathCreationMenu.CollectorRadius.Enabled = false;
|
||||
PathCreationMenu.SpeedZoneRadius.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
internal static void ToggleBlips(bool enabled)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
Paths.SelectMany(x => x.Waypoints).ToList().ForEach(x => x.EnableBlip());
|
||||
}
|
||||
else
|
||||
{
|
||||
Paths.SelectMany(x => x.Waypoints).ToList().ForEach(x => x.DisableBlip());
|
||||
}
|
||||
}
|
||||
|
||||
internal static void ToggleAllPaths(bool disable)
|
||||
{
|
||||
if (disable)
|
||||
{
|
||||
Paths.ForEach(x => x.DisablePath());
|
||||
Game.LogTrivial($"All paths disabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Paths.ForEach(x => x.EnablePath());
|
||||
Game.LogTrivial($"All paths enabled.");
|
||||
}
|
||||
}
|
||||
|
||||
internal static void DeleteAllPaths()
|
||||
{
|
||||
Paths.ForEach(x => x.Delete());
|
||||
Paths.Clear();
|
||||
Game.LogTrivial($"All paths deleted");
|
||||
Game.DisplayNotification($"~o~Scene Manager\n~w~All paths deleted.");
|
||||
MainMenu.BuildMainMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue