mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 23:50:29 +01:00
Updated references based on TrafficPathing refactor
This commit is contained in:
parent
5381d0c189
commit
5f3f22d2c4
4 changed files with 30 additions and 29 deletions
|
|
@ -96,7 +96,7 @@ namespace SceneManager
|
||||||
|
|
||||||
// Clear everything
|
// Clear everything
|
||||||
BarrierMenu.barriers.Clear();
|
BarrierMenu.barriers.Clear();
|
||||||
TrafficPathing.collectedVehicles.Clear();
|
VehicleCollector.collectedVehicles.Clear();
|
||||||
|
|
||||||
Game.LogTrivial($"Scene Manager has been terminated.");
|
Game.LogTrivial($"Scene Manager has been terminated.");
|
||||||
Game.DisplayNotification($"~o~Scene Manager\n~r~[Notice]~w~ The plugin has shut down.");
|
Game.DisplayNotification($"~o~Scene Manager\n~r~[Notice]~w~ The plugin has shut down.");
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ namespace SceneManager
|
||||||
// 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
|
// 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 wd in PathMainMenu.GetPaths()[i].Waypoints)
|
||||||
{
|
{
|
||||||
GameFiber WaypointVehicleCollectorFiber = new GameFiber(() => TrafficPathing.StartCollectingAtWaypoint(PathMainMenu.GetPaths(), PathMainMenu.GetPaths()[i], wd));
|
GameFiber WaypointVehicleCollectorFiber = new GameFiber(() => VehicleCollector.StartCollectingAtWaypoint(PathMainMenu.GetPaths(), PathMainMenu.GetPaths()[i], wd));
|
||||||
WaypointVehicleCollectorFiber.Start();
|
WaypointVehicleCollectorFiber.Start();
|
||||||
|
|
||||||
//GameFiber AssignStopForVehiclesFlagFiber = new GameFiber(() => TrafficPathing.AssignStopForVehiclesFlag(PathMainMenu.GetPaths(), PathMainMenu.GetPaths()[i], wd));
|
//GameFiber AssignStopForVehiclesFlagFiber = new GameFiber(() => TrafficPathing.AssignStopForVehiclesFlag(PathMainMenu.GetPaths(), PathMainMenu.GetPaths()[i], wd));
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ namespace SceneManager
|
||||||
|
|
||||||
private static bool IsInCollectedVehicles(this Vehicle v)
|
private static bool IsInCollectedVehicles(this Vehicle v)
|
||||||
{
|
{
|
||||||
if (v && TrafficPathing.collectedVehicles.ContainsKey(v.LicensePlate))
|
if (v && VehicleCollector.collectedVehicles.ContainsKey(v.LicensePlate))
|
||||||
{
|
{
|
||||||
Game.LogTrivial($"{v.Model.Name} was found in the collection.");
|
Game.LogTrivial($"{v.Model.Name} was found in the collection.");
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -116,7 +116,7 @@ namespace SceneManager
|
||||||
// Before deleting a path, we need to dismiss any vehicles controlled by that path and remove the vehicles from ControlledVehicles
|
// Before deleting a path, we need to dismiss any vehicles controlled by that path and remove the vehicles from ControlledVehicles
|
||||||
//Game.LogTrivial($"Deleting path {index+1}");
|
//Game.LogTrivial($"Deleting path {index+1}");
|
||||||
Game.LogTrivial($"Deleting path {path.PathNum}");
|
Game.LogTrivial($"Deleting path {path.PathNum}");
|
||||||
var pathVehicles = TrafficPathing.collectedVehicles.Where(cv => cv.Value.Path == path.PathNum).ToList();
|
var pathVehicles = VehicleCollector.collectedVehicles.Where(cv => cv.Value.Path == path.PathNum).ToList();
|
||||||
|
|
||||||
Game.LogTrivial($"Removing all vehicles on the path");
|
Game.LogTrivial($"Removing all vehicles on the path");
|
||||||
foreach (KeyValuePair<string, CollectedVehicle> cv in pathVehicles.Where(cv => cv.Value.Vehicle && cv.Value.Vehicle.Driver))
|
foreach (KeyValuePair<string, CollectedVehicle> cv in pathVehicles.Where(cv => cv.Value.Vehicle && cv.Value.Vehicle.Driver))
|
||||||
|
|
@ -129,7 +129,7 @@ namespace SceneManager
|
||||||
cv.Value.Vehicle.IsPersistent = false;
|
cv.Value.Vehicle.IsPersistent = false;
|
||||||
|
|
||||||
//Game.LogTrivial($"{cv.vehicle.Model.Name} cleared from path {cv.path}");
|
//Game.LogTrivial($"{cv.vehicle.Model.Name} cleared from path {cv.path}");
|
||||||
TrafficPathing.collectedVehicles.Remove(cv.Value.LicensePlate);
|
VehicleCollector.collectedVehicles.Remove(cv.Value.LicensePlate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the speed zone so cars don't continue to be affected after the path is deleted
|
// Remove the speed zone so cars don't continue to be affected after the path is deleted
|
||||||
|
|
@ -245,10 +245,10 @@ namespace SceneManager
|
||||||
{
|
{
|
||||||
var nearestWaypoint = paths[directDriver.Index].Waypoints.Where(wp => wp.Position.DistanceTo2D(nearbyVehicle.FrontPosition) < wp.Position.DistanceTo2D(nearbyVehicle.RearPosition)).OrderBy(wp => wp.Position.DistanceTo2D(nearbyVehicle)).ToArray();
|
var nearestWaypoint = paths[directDriver.Index].Waypoints.Where(wp => wp.Position.DistanceTo2D(nearbyVehicle.FrontPosition) < wp.Position.DistanceTo2D(nearbyVehicle.RearPosition)).OrderBy(wp => wp.Position.DistanceTo2D(nearbyVehicle)).ToArray();
|
||||||
|
|
||||||
TrafficPathing.SetVehicleAndDriverPersistence(nearbyVehicle);
|
VehicleCollector.SetVehicleAndDriverPersistence(nearbyVehicle);
|
||||||
if (nearbyVehicle.IsInCollectedVehicles())
|
if (nearbyVehicle.IsInCollectedVehicles())
|
||||||
{
|
{
|
||||||
var vehicle = TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate];
|
var vehicle = VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate];
|
||||||
|
|
||||||
Game.LogTrivial($"[Direct Driver] {nearbyVehicle.Model.Name} already in collection. Clearing tasks.");
|
Game.LogTrivial($"[Direct Driver] {nearbyVehicle.Model.Name} already in collection. Clearing tasks.");
|
||||||
nearbyVehicle.Driver.Tasks.Clear();
|
nearbyVehicle.Driver.Tasks.Clear();
|
||||||
|
|
@ -271,14 +271,14 @@ namespace SceneManager
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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));
|
VehicleCollector.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].PathNum} with {paths[directDriver.Index].Waypoints.Count} waypoints");
|
Game.LogTrivial($"[Direct Driver] {nearbyVehicle.Model.Name} not in collection, adding to collection for path {paths[directDriver.Index].PathNum} with {paths[directDriver.Index].Waypoints.Count} waypoints");
|
||||||
|
|
||||||
if (directOptions.SelectedItem == "First waypoint")
|
if (directOptions.SelectedItem == "First waypoint")
|
||||||
{
|
{
|
||||||
GameFiber.StartNew(() =>
|
GameFiber.StartNew(() =>
|
||||||
{
|
{
|
||||||
TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Driver.Tasks.DriveToPosition(firstWaypoint.Position, firstWaypoint.Speed, (VehicleDrivingFlags)263043, 2f).WaitForCompletion();
|
VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Driver.Tasks.DriveToPosition(firstWaypoint.Position, firstWaypoint.Speed, (VehicleDrivingFlags)263043, 2f).WaitForCompletion();
|
||||||
|
|
||||||
for (int nextWaypoint = firstWaypoint.Number; nextWaypoint < paths[directDriver.Index].Waypoints.Count; nextWaypoint++)
|
for (int nextWaypoint = firstWaypoint.Number; nextWaypoint < paths[directDriver.Index].Waypoints.Count; nextWaypoint++)
|
||||||
{
|
{
|
||||||
|
|
@ -288,28 +288,28 @@ namespace SceneManager
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Game.LogTrivial($"{TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Model.Name} is driving to waypoint {paths[directDriver.Index].Waypoints[nextWaypoint].Number}");
|
Game.LogTrivial($"{VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Model.Name} is driving to waypoint {paths[directDriver.Index].Waypoints[nextWaypoint].Number}");
|
||||||
if (paths[directDriver.Index].Waypoints.ElementAtOrDefault(nextWaypoint) != null && !TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate].StoppedAtWaypoint)
|
if (paths[directDriver.Index].Waypoints.ElementAtOrDefault(nextWaypoint) != null && !VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate].StoppedAtWaypoint)
|
||||||
{
|
{
|
||||||
TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Driver.Tasks.DriveToPosition(paths[directDriver.Index].Waypoints[nextWaypoint].Position, paths[directDriver.Index].Waypoints[nextWaypoint].Speed, (VehicleDrivingFlags)263043, 2f).WaitForCompletion();
|
VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Driver.Tasks.DriveToPosition(paths[directDriver.Index].Waypoints[nextWaypoint].Position, paths[directDriver.Index].Waypoints[nextWaypoint].Speed, (VehicleDrivingFlags)263043, 2f).WaitForCompletion();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paths[directDriver.Index].Waypoints.ElementAtOrDefault(nextWaypoint) != null && paths[directDriver.Index].Waypoints[nextWaypoint].DrivingFlag == VehicleDrivingFlags.StopAtDestination)
|
if (paths[directDriver.Index].Waypoints.ElementAtOrDefault(nextWaypoint) != null && paths[directDriver.Index].Waypoints[nextWaypoint].DrivingFlag == VehicleDrivingFlags.StopAtDestination)
|
||||||
{
|
{
|
||||||
Game.LogTrivial($"{TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Model.Name} stopping at waypoint.");
|
Game.LogTrivial($"{VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Model.Name} stopping at waypoint.");
|
||||||
TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Driver.Tasks.PerformDrivingManeuver(VehicleManeuver.GoForwardStraightBraking);
|
VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Driver.Tasks.PerformDrivingManeuver(VehicleManeuver.GoForwardStraightBraking);
|
||||||
TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate].SetStoppedAtWaypoint(true);
|
VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate].SetStoppedAtWaypoint(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Game.LogTrivial($"{TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Model.Name} all tasks complete.");
|
Game.LogTrivial($"{VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Model.Name} all tasks complete.");
|
||||||
TrafficPathing.DismissDriver(TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate]);
|
AITasking.DismissDriver(VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameFiber.StartNew(() =>
|
GameFiber.StartNew(() =>
|
||||||
{
|
{
|
||||||
TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Driver.Tasks.DriveToPosition(nearestWaypoint[0].Position, nearestWaypoint[0].Speed, (VehicleDrivingFlags)263043, 2f).WaitForCompletion();
|
VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Driver.Tasks.DriveToPosition(nearestWaypoint[0].Position, nearestWaypoint[0].Speed, (VehicleDrivingFlags)263043, 2f).WaitForCompletion();
|
||||||
|
|
||||||
for (int nextWaypoint = nearestWaypoint[0].Number; nextWaypoint < paths[directDriver.Index].Waypoints.Count; nextWaypoint++)
|
for (int nextWaypoint = nearestWaypoint[0].Number; nextWaypoint < paths[directDriver.Index].Waypoints.Count; nextWaypoint++)
|
||||||
{
|
{
|
||||||
|
|
@ -319,21 +319,21 @@ namespace SceneManager
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Game.LogTrivial($"{TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Model.Name} is driving to waypoint {paths[directDriver.Index].Waypoints[nextWaypoint].Number}");
|
Game.LogTrivial($"{VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Model.Name} is driving to waypoint {paths[directDriver.Index].Waypoints[nextWaypoint].Number}");
|
||||||
if (paths[directDriver.Index].Waypoints.ElementAtOrDefault(nextWaypoint) != null && !TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate].StoppedAtWaypoint)
|
if (paths[directDriver.Index].Waypoints.ElementAtOrDefault(nextWaypoint) != null && !VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate].StoppedAtWaypoint)
|
||||||
{
|
{
|
||||||
TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Driver.Tasks.DriveToPosition(paths[directDriver.Index].Waypoints[nextWaypoint].Position, paths[directDriver.Index].Waypoints[nextWaypoint].Speed, (VehicleDrivingFlags)263043, 2f).WaitForCompletion();
|
VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Driver.Tasks.DriveToPosition(paths[directDriver.Index].Waypoints[nextWaypoint].Position, paths[directDriver.Index].Waypoints[nextWaypoint].Speed, (VehicleDrivingFlags)263043, 2f).WaitForCompletion();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paths[directDriver.Index].Waypoints.ElementAtOrDefault(nextWaypoint) != null && paths[directDriver.Index].Waypoints[nextWaypoint].DrivingFlag == VehicleDrivingFlags.StopAtDestination)
|
if (paths[directDriver.Index].Waypoints.ElementAtOrDefault(nextWaypoint) != null && paths[directDriver.Index].Waypoints[nextWaypoint].DrivingFlag == VehicleDrivingFlags.StopAtDestination)
|
||||||
{
|
{
|
||||||
Game.LogTrivial($"{TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Model.Name} stopping at waypoint.");
|
Game.LogTrivial($"{VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Model.Name} stopping at waypoint.");
|
||||||
TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Driver.Tasks.PerformDrivingManeuver(VehicleManeuver.GoForwardStraightBraking);
|
VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Driver.Tasks.PerformDrivingManeuver(VehicleManeuver.GoForwardStraightBraking);
|
||||||
TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate].SetStoppedAtWaypoint(true);
|
VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate].SetStoppedAtWaypoint(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Game.LogTrivial($"{TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Model.Name} all tasks complete.");
|
Game.LogTrivial($"{VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate].Vehicle.Model.Name} all tasks complete.");
|
||||||
TrafficPathing.DismissDriver(TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate]);
|
AITasking.DismissDriver(VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -351,7 +351,7 @@ namespace SceneManager
|
||||||
Game.LogTrivial($"Dismiss from path");
|
Game.LogTrivial($"Dismiss from path");
|
||||||
if (nearbyVehicle.IsInCollectedVehicles())
|
if (nearbyVehicle.IsInCollectedVehicles())
|
||||||
{
|
{
|
||||||
var controlledVehicle = TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate];
|
var controlledVehicle = VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate];
|
||||||
controlledVehicle.SetDismissNow(true);
|
controlledVehicle.SetDismissNow(true);
|
||||||
controlledVehicle.Vehicle.Driver.Tasks.Clear();
|
controlledVehicle.Vehicle.Driver.Tasks.Clear();
|
||||||
controlledVehicle.Vehicle.Driver.Dismiss();
|
controlledVehicle.Vehicle.Driver.Dismiss();
|
||||||
|
|
@ -367,7 +367,7 @@ namespace SceneManager
|
||||||
Game.LogTrivial($"Dismiss from waypoint");
|
Game.LogTrivial($"Dismiss from waypoint");
|
||||||
if (nearbyVehicle.IsInCollectedVehicles())
|
if (nearbyVehicle.IsInCollectedVehicles())
|
||||||
{
|
{
|
||||||
var controlledVehicle = TrafficPathing.collectedVehicles[nearbyVehicle.LicensePlate];
|
var controlledVehicle = VehicleCollector.collectedVehicles[nearbyVehicle.LicensePlate];
|
||||||
controlledVehicle.SetStoppedAtWaypoint(false);
|
controlledVehicle.SetStoppedAtWaypoint(false);
|
||||||
controlledVehicle.Vehicle.Driver.Tasks.Clear();
|
controlledVehicle.Vehicle.Driver.Tasks.Clear();
|
||||||
controlledVehicle.Vehicle.Driver.Dismiss();
|
controlledVehicle.Vehicle.Driver.Dismiss();
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="AITasking.cs" />
|
||||||
<Compile Include="DebugGraphics.cs" />
|
<Compile Include="DebugGraphics.cs" />
|
||||||
<Compile Include="Menus\BarrierMenu.cs" />
|
<Compile Include="Menus\BarrierMenu.cs" />
|
||||||
<Compile Include="Object Classes\CollectedVehicle.cs" />
|
<Compile Include="Object Classes\CollectedVehicle.cs" />
|
||||||
|
|
@ -65,7 +66,7 @@
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Menus\PathMainMenu.cs" />
|
<Compile Include="Menus\PathMainMenu.cs" />
|
||||||
<Compile Include="Menus\SettingsMenu.cs" />
|
<Compile Include="Menus\SettingsMenu.cs" />
|
||||||
<Compile Include="TrafficPathing.cs" />
|
<Compile Include="VehicleCollector.cs" />
|
||||||
<Compile Include="Verification.cs" />
|
<Compile Include="Verification.cs" />
|
||||||
<Compile Include="Object Classes\Waypoint.cs" />
|
<Compile Include="Object Classes\Waypoint.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue