mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 23:50:29 +01:00
Initial commit
This commit is contained in:
parent
296206f5b9
commit
fd12e1bea2
9 changed files with 1031 additions and 0 deletions
43
SceneManager/Utils/DismissDriver.cs
Normal file
43
SceneManager/Utils/DismissDriver.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
using Rage;
|
||||
using SceneManager.Objects;
|
||||
using System.Linq;
|
||||
|
||||
namespace SceneManager.Utils
|
||||
{
|
||||
internal static class DismissDriver
|
||||
{
|
||||
internal static void Dismiss(int dismissIndex)
|
||||
{
|
||||
var nearbyVehicle = Game.LocalPlayer.Character.GetNearbyVehicles(16).FirstOrDefault(v => v != Game.LocalPlayer.Character.CurrentVehicle && v.VehicleAndDriverValid());
|
||||
if (!nearbyVehicle)
|
||||
{
|
||||
Game.LogTrivial($"Nearby vehicle is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(dismissIndex == (int)Utils.Dismiss.FromWorld)
|
||||
{
|
||||
// Have to loop because sometimes police peds don't get deleted properly
|
||||
// The path should handle removing the deleted driver/vehicle from its list of collected vehicles
|
||||
while (nearbyVehicle && nearbyVehicle.HasOccupants)
|
||||
{
|
||||
nearbyVehicle.Occupants.ToList().ForEach(x => x.Delete());
|
||||
GameFiber.Yield();
|
||||
}
|
||||
if (nearbyVehicle)
|
||||
{
|
||||
nearbyVehicle.Delete();
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
CollectedVehicle collectedVehicle = PathManager.Paths.SelectMany(x => x.CollectedVehicles).FirstOrDefault(x => x.Vehicle == nearbyVehicle);
|
||||
if(collectedVehicle != null)
|
||||
{
|
||||
collectedVehicle.Dismiss((Dismiss)dismissIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue