mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 15:40:29 +01:00
Fixed an issue where dismissing a vehicle from the last waypoint of a path was not working
This commit is contained in:
parent
13d22d218d
commit
cf0aa75644
2 changed files with 24 additions and 19 deletions
|
|
@ -215,6 +215,8 @@ namespace SceneManager
|
|||
{
|
||||
GameFiber.Yield();
|
||||
}
|
||||
Rage.Native.NativeFunction.Natives.x260BE8F09E326A20(collectedVehicle.Vehicle, 0f, 1, true);
|
||||
collectedVehicle.Driver.Tasks.CruiseWithVehicle(5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,15 +56,7 @@ namespace SceneManager
|
|||
Driver.Tasks.Clear();
|
||||
if(StoppedAtWaypoint)
|
||||
{
|
||||
Logger.Log($"Unstucking stopped vehicle");
|
||||
Rage.Native.NativeFunction.Natives.x260BE8F09E326A20(Vehicle, 0f, 1, true);
|
||||
GameFiber.StartNew(() =>
|
||||
{
|
||||
while(Vehicle && Vehicle.Speed < 1f)
|
||||
{
|
||||
GameFiber.Yield();
|
||||
}
|
||||
});
|
||||
Logger.Log($"Unstucking {Vehicle.Model.Name}");
|
||||
StoppedAtWaypoint = false;
|
||||
}
|
||||
|
||||
|
|
@ -72,12 +64,6 @@ namespace SceneManager
|
|||
{
|
||||
Logger.Log($"Dismissed from waypoint.");
|
||||
SkipWaypoint = true;
|
||||
//GameFiber.StartNew(() =>
|
||||
//{
|
||||
// GameFiber.Sleep(100);
|
||||
// SkipWaypoint = false;
|
||||
// Logger.Log($"SkipWaypoint false");
|
||||
//});
|
||||
}
|
||||
|
||||
if(dismissOption == DismissOption.FromWaypoint && CurrentWaypoint.Number == Path.Waypoints.Count || dismissOption == DismissOption.FromPath)
|
||||
|
|
@ -86,12 +72,29 @@ namespace SceneManager
|
|||
GameFiber.StartNew(() =>
|
||||
{
|
||||
// check if the vehicle is near any of the path's collector waypoints
|
||||
var nearestCollectorWaypoint = Path.Waypoints.Where(wp => wp.IsCollector && Vehicle.DistanceTo2D(wp.Position) <= wp.CollectorRadius * 2).FirstOrDefault();
|
||||
while (nearestCollectorWaypoint != null && Vehicle && Driver && Vehicle.DistanceTo2D(nearestCollectorWaypoint.Position) <= nearestCollectorWaypoint.CollectorRadius * 2)
|
||||
//var nearestCollectorWaypoint = Path.Waypoints.Where(wp => wp.IsCollector && Vehicle.DistanceTo2D(wp.Position) <= wp.CollectorRadius * 2).FirstOrDefault();
|
||||
var nearestCollectorWaypoint = Path.Waypoints.Where(wp => wp.IsCollector).OrderBy(wp => Vehicle.DistanceTo2D(wp.Position)).FirstOrDefault();
|
||||
if(nearestCollectorWaypoint != null && Vehicle.FrontPosition.DistanceTo2D(nearestCollectorWaypoint.Position) <= 5f)
|
||||
{
|
||||
//Game.LogTrivial($"{Vehicle.Model.Name} is too close to the collector to be fully dismissed.");
|
||||
GameFiber.Yield();
|
||||
while (nearestCollectorWaypoint != null && Vehicle && Driver && Vehicle.FrontPosition.DistanceTo2D(nearestCollectorWaypoint.Position) <= 5f)
|
||||
{
|
||||
//Game.LogTrivial($"{Vehicle.Model.Name} is too close to the collector to be fully dismissed.");
|
||||
GameFiber.Yield();
|
||||
}
|
||||
}
|
||||
else if(nearestCollectorWaypoint != null)
|
||||
{
|
||||
while (nearestCollectorWaypoint != null && Vehicle && Driver && Vehicle.FrontPosition.DistanceTo2D(nearestCollectorWaypoint.Position) <= nearestCollectorWaypoint.CollectorRadius * 2)
|
||||
{
|
||||
//Game.LogTrivial($"{Vehicle.Model.Name} is too close to the collector to be fully dismissed.");
|
||||
GameFiber.Yield();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Log($"Nearest collector is null");
|
||||
}
|
||||
|
||||
|
||||
if (!Vehicle || !Driver)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue