mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 15:40:29 +01:00
Added Directed property and set all initial bool properties to false. Refactored Dismiss function.
This commit is contained in:
parent
4b4f596024
commit
64587347d7
1 changed files with 63 additions and 35 deletions
|
|
@ -10,9 +10,10 @@ namespace SceneManager
|
||||||
internal Path Path { get; set; }
|
internal Path Path { get; set; }
|
||||||
internal Waypoint CurrentWaypoint { get; set; }
|
internal Waypoint CurrentWaypoint { get; set; }
|
||||||
internal Waypoint NextWaypoint { get; private set; }
|
internal Waypoint NextWaypoint { get; private set; }
|
||||||
internal bool StoppedAtWaypoint { get; set; }
|
internal bool StoppedAtWaypoint { get; set; } = false;
|
||||||
internal bool Dismissed { get; set; }
|
internal bool Dismissed { get; set; } = false;
|
||||||
internal bool SkipWaypoint { get; set; }
|
internal bool Directed { get; set; } = false;
|
||||||
|
internal bool SkipWaypoint { get; set; } = false;
|
||||||
|
|
||||||
internal CollectedVehicle(Vehicle vehicle, Path path, Waypoint currentWaypoint)
|
internal CollectedVehicle(Vehicle vehicle, Path path, Waypoint currentWaypoint)
|
||||||
{
|
{
|
||||||
|
|
@ -29,49 +30,76 @@ namespace SceneManager
|
||||||
Path = path;
|
Path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Dismiss()
|
internal void Dismiss(DismissOption dismissOption = DismissOption.FromPath)
|
||||||
{
|
{
|
||||||
GameFiber.StartNew(() =>
|
if (!Vehicle || !Driver)
|
||||||
{
|
{
|
||||||
if (!Vehicle || !Driver)
|
return;
|
||||||
{
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
Dismissed = true;
|
|
||||||
StoppedAtWaypoint = false;
|
|
||||||
|
|
||||||
Driver.Tasks.Clear();
|
if (dismissOption == DismissOption.FromWorld)
|
||||||
Driver.Tasks.PerformDrivingManeuver(Vehicle, VehicleManeuver.GoForwardWithCustomSteeringAngle, 3);
|
{
|
||||||
|
Game.LogTrivial($"Dismissed {Vehicle.Model.Name} from the world");
|
||||||
|
Vehicle.Driver.Delete();
|
||||||
|
Vehicle.Delete();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (Driver.GetAttachedBlip())
|
Dismissed = true;
|
||||||
|
Dismissed = false;
|
||||||
|
Driver.Tasks.Clear();
|
||||||
|
if(StoppedAtWaypoint)
|
||||||
|
{
|
||||||
|
Logger.Log($"Unstucking stopped vehicle");
|
||||||
|
Rage.Native.NativeFunction.Natives.x260BE8F09E326A20(Vehicle, 0f, 1, true);
|
||||||
|
GameFiber.StartNew(() =>
|
||||||
{
|
{
|
||||||
Driver.GetAttachedBlip().Delete();
|
while(Vehicle.Speed < 1f)
|
||||||
}
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
if (nearestCollectorWaypoint != null)
|
|
||||||
{
|
|
||||||
while (nearestCollectorWaypoint != null && Vehicle && Driver && Vehicle.DistanceTo2D(nearestCollectorWaypoint.Position) <= nearestCollectorWaypoint.CollectorRadius * 2)
|
|
||||||
{
|
{
|
||||||
//Game.LogTrivial($"{_vehicle.Model.Name} is too close to the collector to be fully dismissed.");
|
|
||||||
GameFiber.Yield();
|
GameFiber.Yield();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
StoppedAtWaypoint = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Vehicle || !Driver)
|
if(dismissOption == DismissOption.FromWaypoint && CurrentWaypoint.Number != Path.Waypoints.Count)
|
||||||
|
{
|
||||||
|
Logger.Log($"Dismissed from waypoint.");
|
||||||
|
SkipWaypoint = true;
|
||||||
|
SkipWaypoint = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dismissOption == DismissOption.FromWaypoint && CurrentWaypoint.Number == Path.Waypoints.Count || dismissOption == DismissOption.FromPath)
|
||||||
|
{
|
||||||
|
Logger.Log($"Dismissed from path.");
|
||||||
|
GameFiber.StartNew(() =>
|
||||||
{
|
{
|
||||||
return;
|
// 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)
|
||||||
|
{
|
||||||
|
//Game.LogTrivial($"{Vehicle.Model.Name} is too close to the collector to be fully dismissed.");
|
||||||
|
GameFiber.Yield();
|
||||||
|
}
|
||||||
|
|
||||||
VehicleCollector.collectedVehicles.Remove(this);
|
if (!Vehicle || !Driver)
|
||||||
Logger.Log($"{Vehicle.Model.Name} dismissed successfully.");
|
{
|
||||||
Driver.BlockPermanentEvents = false;
|
return;
|
||||||
Driver.Dismiss();
|
}
|
||||||
Vehicle.IsSirenOn = false;
|
|
||||||
Vehicle.IsSirenSilent = true;
|
VehicleCollector.collectedVehicles.Remove(this);
|
||||||
Vehicle.Dismiss();
|
Logger.Log($"{Vehicle.Model.Name} dismissed successfully.");
|
||||||
});
|
if (Driver.GetAttachedBlip())
|
||||||
|
{
|
||||||
|
Driver.GetAttachedBlip().Delete();
|
||||||
|
}
|
||||||
|
Driver.BlockPermanentEvents = false;
|
||||||
|
Driver.Dismiss();
|
||||||
|
Vehicle.IsSirenOn = false;
|
||||||
|
Vehicle.IsSirenSilent = true;
|
||||||
|
Vehicle.Dismiss();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue