mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-12 08:00:30 +01:00
Made GetNearbyVehiclesForCollection a local function within LoopForNearbyValidVehicles. Removed condition regarding a deprecated TasksAssigned property.
This commit is contained in:
parent
480ef8975f
commit
fdd454783f
1 changed files with 7 additions and 17 deletions
|
|
@ -34,39 +34,29 @@ namespace SceneManager
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Game.LogTrivial($"Vehicle: {vehicle.Model.Name}, Waypoint collector radius: {waypoint.CollectorRadius}, Distance to waypoint: {vehicle.DistanceTo2D(waypoint.Position)}");
|
Logger.Log($"Vehicle: {vehicle.Model.Name}, Waypoint collector radius: {waypoint.CollectorRadius}, Distance to waypoint: {vehicle.DistanceTo2D(waypoint.Position)}");
|
||||||
|
|
||||||
var collectedVehicle = collectedVehicles.Where(cv => cv.Vehicle == vehicle) as CollectedVehicle;
|
var collectedVehicle = collectedVehicles.Where(cv => cv.Vehicle == vehicle).FirstOrDefault();
|
||||||
// If the vehicle is not in the collection yet
|
// If the vehicle is not in the collection yet
|
||||||
if(collectedVehicle == null)
|
if(collectedVehicle == null)
|
||||||
{
|
{
|
||||||
SetVehicleAndDriverPersistence(vehicle);
|
SetVehicleAndDriverPersistence(vehicle);
|
||||||
CollectedVehicle newCollectedVehicle = AddVehicleToCollection(path, waypoint, vehicle);
|
CollectedVehicle newCollectedVehicle = AddVehicleToCollection(path, waypoint, vehicle);
|
||||||
newCollectedVehicle.TasksAssigned = true;
|
|
||||||
|
|
||||||
GameFiber AssignTasksFiber = new GameFiber(() => AITasking.AssignWaypointTasks(newCollectedVehicle, path.Waypoints, waypoint));
|
GameFiber AssignTasksFiber = new GameFiber(() => AITasking.AssignWaypointTasks(newCollectedVehicle, path.Waypoints, waypoint));
|
||||||
AssignTasksFiber.Start();
|
AssignTasksFiber.Start();
|
||||||
}
|
}
|
||||||
// If the vehicle is in the collection, but has no tasks
|
|
||||||
else if (!collectedVehicle.TasksAssigned)
|
|
||||||
{
|
|
||||||
Game.LogTrivial($"[WaypointVehicleCollector] {vehicle.Model.Name} already in collection, but with no tasks. Assigning tasks.");
|
|
||||||
collectedVehicle.TasksAssigned = true;
|
|
||||||
|
|
||||||
GameFiber AssignTasksFiber = new GameFiber(() => AITasking.AssignWaypointTasks(collectedVehicle, path.Waypoints, waypoint));
|
|
||||||
AssignTasksFiber.Start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static Vehicle[] GetNearbyVehiclesForCollection(Vector3 collectorWaypointPosition, float collectorRadius)
|
Vehicle[] GetNearbyVehiclesForCollection(Vector3 collectorWaypointPosition, float collectorRadius)
|
||||||
{
|
{
|
||||||
return (from v in World.GetAllVehicles() where v.DistanceTo2D(collectorWaypointPosition) <= collectorRadius && Math.Abs(collectorWaypointPosition.Z - v.Position.Z) < 3 && v.IsValidForCollection() select v).ToArray();
|
return (from v in World.GetAllVehicles() where v.DistanceTo2D(collectorWaypointPosition) <= collectorRadius && Math.Abs(collectorWaypointPosition.Z - v.Position.Z) < 3 && v.IsValidForCollection() select v).ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CollectedVehicle AddVehicleToCollection(Path path, Waypoint waypoint, Vehicle v)
|
private static CollectedVehicle AddVehicleToCollection(Path path, Waypoint waypoint, Vehicle v)
|
||||||
{
|
{
|
||||||
var collectedVehicle = new CollectedVehicle(v, path, waypoint, false);
|
var collectedVehicle = new CollectedVehicle(v, path, waypoint);
|
||||||
collectedVehicles.Add(collectedVehicle);
|
collectedVehicles.Add(collectedVehicle);
|
||||||
Game.LogTrivial($"[WaypointVehicleCollector] Added {v.Model.Name} to collection from path {path.Number}, waypoint {waypoint.Number}.");
|
Game.LogTrivial($"[WaypointVehicleCollector] Added {v.Model.Name} to collection from path {path.Number}, waypoint {waypoint.Number}.");
|
||||||
return collectedVehicle;
|
return collectedVehicle;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue