1
Fork 0
mirror of https://github.com/thegeneralist01/Scene-Manager-DevRepo synced 2026-01-10 15:20:29 +01:00

Added check for vehicle's driver before creating new CollectedPed

This commit is contained in:
Rich Dunne 2021-05-23 08:32:51 -06:00
parent f19f2bc79d
commit c3e401193b

View file

@ -237,14 +237,25 @@ namespace SceneManager.Paths
int checksDone = 0;
var collectorWaypoints = Waypoints.Where(x => x.IsCollector);
var vehiclesInWorld = World.GetAllVehicles().Where(x => x);
foreach (Waypoint waypoint in collectorWaypoints.ToList())
{
foreach (Vehicle vehicle in vehiclesInWorld)
foreach (Vehicle vehicle in World.GetAllVehicles().Where(x => x))
{
if (vehicle.IsNearCollectorWaypoint(waypoint) && vehicle.IsValidForPathCollection(this))
{
while(!vehicle.Driver)
{
GameFiber.Yield();
if (!vehicle)
{
break;
}
}
if (!vehicle)
{
continue;
}
CollectedPeds.Add(new CollectedPed(vehicle.Driver, this, waypoint));
}