mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 23:50:29 +01:00
Refactored Dismiss function to use local functions for each type of dismissal
This commit is contained in:
parent
f0a5fb6d80
commit
159f7d28a3
1 changed files with 41 additions and 15 deletions
|
|
@ -38,6 +38,29 @@ namespace SceneManager
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dismissOption == DismissOption.FromWorld)
|
if (dismissOption == DismissOption.FromWorld)
|
||||||
|
{
|
||||||
|
DismissFromWorld();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Driver.Tasks.Clear();
|
||||||
|
if(StoppedAtWaypoint)
|
||||||
|
{
|
||||||
|
Logger.Log($"Unstucking {Vehicle.Model.Name}");
|
||||||
|
StoppedAtWaypoint = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dismissOption == DismissOption.FromWaypoint)
|
||||||
|
{
|
||||||
|
DismissFromWaypoint();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dismissOption == DismissOption.FromPath)
|
||||||
|
{
|
||||||
|
DismissFromPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DismissFromWorld()
|
||||||
{
|
{
|
||||||
Game.LogTrivial($"Dismissed {Vehicle.Model.Name} from the world");
|
Game.LogTrivial($"Dismissed {Vehicle.Model.Name} from the world");
|
||||||
while (Vehicle.HasOccupants)
|
while (Vehicle.HasOccupants)
|
||||||
|
|
@ -50,23 +73,26 @@ namespace SceneManager
|
||||||
GameFiber.Yield();
|
GameFiber.Yield();
|
||||||
}
|
}
|
||||||
Vehicle.Delete();
|
Vehicle.Delete();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Driver.Tasks.Clear();
|
void DismissFromWaypoint()
|
||||||
if(StoppedAtWaypoint)
|
|
||||||
{
|
{
|
||||||
Logger.Log($"Unstucking {Vehicle.Model.Name}");
|
if (CurrentWaypoint == null || Path == null)
|
||||||
StoppedAtWaypoint = false;
|
{
|
||||||
|
Logger.Log($"CurrentWaypoint or Path are null");
|
||||||
}
|
}
|
||||||
|
else if (CurrentWaypoint?.Number != Path?.Waypoints.Count)
|
||||||
if(dismissOption == DismissOption.FromWaypoint && CurrentWaypoint.Number != Path.Waypoints.Count)
|
|
||||||
{
|
{
|
||||||
Logger.Log($"Dismissed from waypoint.");
|
Logger.Log($"Dismissed from waypoint.");
|
||||||
SkipWaypoint = true;
|
SkipWaypoint = true;
|
||||||
}
|
}
|
||||||
|
else if (CurrentWaypoint?.Number == Path?.Waypoints.Count)
|
||||||
|
{
|
||||||
|
DismissFromPath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(dismissOption == DismissOption.FromWaypoint && CurrentWaypoint.Number == Path.Waypoints.Count || dismissOption == DismissOption.FromPath)
|
void DismissFromPath()
|
||||||
{
|
{
|
||||||
Logger.Log($"Dismissing from path");
|
Logger.Log($"Dismissing from path");
|
||||||
Dismissed = true;
|
Dismissed = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue