mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 07:30:40 +01:00
Moved CollectedVehicle object within Object Classes folder
This commit is contained in:
parent
8913585d7f
commit
3902ab1522
2 changed files with 1 additions and 195 deletions
|
|
@ -1,194 +0,0 @@
|
|||
using Rage;
|
||||
using System.Linq;
|
||||
|
||||
namespace SceneManager
|
||||
{
|
||||
internal class CollectedVehicle
|
||||
{
|
||||
internal Ped Driver { get; set; }
|
||||
internal Vehicle Vehicle { get; set; }
|
||||
internal Path Path { get; set; }
|
||||
internal Waypoint CurrentWaypoint { get; set; }
|
||||
internal Waypoint NextWaypoint { get; private set; }
|
||||
internal bool StoppedAtWaypoint { get; set; } = false;
|
||||
internal bool Dismissed { get; set; } = false;
|
||||
internal bool Directed { get; set; } = false;
|
||||
internal bool SkipWaypoint { get; set; } = false;
|
||||
internal bool ReadyForDirectTasks { get; set; } = true;
|
||||
|
||||
internal CollectedVehicle(Vehicle vehicle, Path path, Waypoint currentWaypoint)
|
||||
{
|
||||
Vehicle = vehicle;
|
||||
Driver = Vehicle.Driver;
|
||||
Path = path;
|
||||
CurrentWaypoint = currentWaypoint;
|
||||
SetPersistence();
|
||||
}
|
||||
|
||||
internal CollectedVehicle(Vehicle vehicle, Path path)
|
||||
{
|
||||
Vehicle = vehicle;
|
||||
Driver = vehicle.Driver;
|
||||
Path = path;
|
||||
SetPersistence();
|
||||
}
|
||||
|
||||
internal void SetPersistence()
|
||||
{
|
||||
Vehicle.IsPersistent = true;
|
||||
Driver.IsPersistent = true;
|
||||
Driver.BlockPermanentEvents = true;
|
||||
//Logger.Log($"{Vehicle.Model.Name} and driver are now persistent.");
|
||||
}
|
||||
|
||||
internal void Dismiss(DismissOption dismissOption = DismissOption.FromPath, Path newPath = null)
|
||||
{
|
||||
if (!Vehicle || !Driver)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (dismissOption == DismissOption.FromWorld)
|
||||
{
|
||||
DismissFromWorld();
|
||||
return;
|
||||
}
|
||||
|
||||
if (dismissOption == DismissOption.FromPlayer)
|
||||
{
|
||||
Dismissed = true;
|
||||
if (Driver)
|
||||
{
|
||||
Driver.Dismiss();
|
||||
}
|
||||
if (Vehicle)
|
||||
{
|
||||
Vehicle.Dismiss();
|
||||
}
|
||||
Rage.Native.NativeFunction.Natives.x260BE8F09E326A20(Vehicle, 0f, 1, true);
|
||||
Path.CollectedVehicles.Remove(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if(StoppedAtWaypoint)
|
||||
{
|
||||
//Logger.Log($"Unstucking {Vehicle.Model.Name}");
|
||||
StoppedAtWaypoint = false;
|
||||
Rage.Native.NativeFunction.Natives.x260BE8F09E326A20(Vehicle, 0f, 1, true);
|
||||
Driver.Tasks.CruiseWithVehicle(5f);
|
||||
}
|
||||
Driver.Tasks.Clear();
|
||||
|
||||
if (dismissOption == DismissOption.FromWaypoint)
|
||||
{
|
||||
DismissFromWaypoint();
|
||||
}
|
||||
|
||||
if (dismissOption == DismissOption.FromPath)
|
||||
{
|
||||
DismissFromPath();
|
||||
}
|
||||
|
||||
if(dismissOption == DismissOption.FromDirected)
|
||||
{
|
||||
DismissFromDirect();
|
||||
}
|
||||
|
||||
void DismissFromWorld()
|
||||
{
|
||||
Game.LogTrivial($"Dismissed {Vehicle.Model.Name} from the world");
|
||||
while (Vehicle.HasOccupants)
|
||||
{
|
||||
foreach (Ped occupant in Vehicle.Occupants)
|
||||
{
|
||||
occupant.Dismiss();
|
||||
occupant.Delete();
|
||||
}
|
||||
GameFiber.Yield();
|
||||
}
|
||||
Vehicle.Delete();
|
||||
}
|
||||
|
||||
void DismissFromWaypoint()
|
||||
{
|
||||
if (CurrentWaypoint == null || Path == null)
|
||||
{
|
||||
Logger.Log($"CurrentWaypoint or Path are null");
|
||||
}
|
||||
else if (CurrentWaypoint?.Number != Path?.Waypoints.Count)
|
||||
{
|
||||
Logger.Log($"Dismissed from waypoint.");
|
||||
SkipWaypoint = true;
|
||||
}
|
||||
else if (CurrentWaypoint?.Number == Path?.Waypoints.Count)
|
||||
{
|
||||
DismissFromPath();
|
||||
}
|
||||
}
|
||||
|
||||
void DismissFromPath()
|
||||
{
|
||||
Logger.Log($"Dismissing from path");
|
||||
Dismissed = true;
|
||||
|
||||
// Check if the vehicle is near any of the path's collector waypoints
|
||||
GameFiber.StartNew(() =>
|
||||
{
|
||||
var nearestCollectorWaypoint = Path.Waypoints.Where(wp => wp.IsCollector).OrderBy(wp => Vehicle.DistanceTo2D(wp.Position)).FirstOrDefault();
|
||||
if (nearestCollectorWaypoint != null)
|
||||
{
|
||||
// Enabling this will keep the menu, but the dismissed vehicle is immediately re - collected
|
||||
while (nearestCollectorWaypoint != null && Vehicle && Vehicle.HasDriver && Driver && Driver.IsAlive && Vehicle.FrontPosition.DistanceTo2D(nearestCollectorWaypoint.Position) <= nearestCollectorWaypoint.CollectorRadius)
|
||||
{
|
||||
//Game.LogTrivial($"{Vehicle.Model.Name} is within 2x collector radius, cannot be fully dismissed yet.");
|
||||
GameFiber.Yield();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Log($"Nearest collector is null");
|
||||
}
|
||||
|
||||
if (!Vehicle || !Driver)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Directed)
|
||||
{
|
||||
Path.CollectedVehicles.Remove(this);
|
||||
Logger.Log($"{Vehicle.Model.Name} dismissed successfully.");
|
||||
if (Driver)
|
||||
{
|
||||
if (Driver.GetAttachedBlip())
|
||||
{
|
||||
Driver.GetAttachedBlip().Delete();
|
||||
}
|
||||
Driver.BlockPermanentEvents = false;
|
||||
Driver.Dismiss();
|
||||
}
|
||||
if (Vehicle)
|
||||
{
|
||||
Vehicle.IsSirenOn = false;
|
||||
Vehicle.IsSirenSilent = true;
|
||||
Vehicle.Dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void DismissFromDirect()
|
||||
{
|
||||
Dismissed = true;
|
||||
Directed = true;
|
||||
if (newPath != null)
|
||||
{
|
||||
newPath.CollectedVehicles.Add(this);
|
||||
Path.CollectedVehicles.Remove(this);
|
||||
}
|
||||
Driver.Tasks.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AITasking.cs" />
|
||||
<Compile Include="CollectedVehicle.cs" />
|
||||
<Compile Include="Object Classes\CollectedVehicle.cs" />
|
||||
<Compile Include="Logger.cs" />
|
||||
<Compile Include="Object Classes\Barrier.cs" />
|
||||
<Compile Include="Hints.cs" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue