Airborne transports only land to (un)load.

This commit is contained in:
tovl
2019-06-30 13:41:01 +00:00
committed by reaperrr
parent 76422933f6
commit 5920de1384
15 changed files with 211 additions and 97 deletions

View File

@@ -150,44 +150,14 @@ namespace OpenRA.Mods.Common.Scripting
else
{
var aircraft = transport.TraitOrDefault<Aircraft>();
// Scripted cargo aircraft must turn to default position before unloading.
// TODO: pass facing through UnloadCargo instead.
if (aircraft != null)
{
var destination = entryPath.Last();
// Try to find an alternative landing spot if we can't land at the current destination
if (!aircraft.CanLand(destination) && dropRange > 0)
{
var locomotors = cargo.Passengers
.Select(a => a.Info.TraitInfoOrDefault<MobileInfo>())
.Where(m => m != null)
.Distinct()
.Select(m => m.LocomotorInfo)
.ToList();
foreach (var c in transport.World.Map.FindTilesInCircle(destination, dropRange))
{
if (!aircraft.CanLand(c))
continue;
if (!locomotors.All(m => domainIndex.IsPassable(destination, c, m)))
continue;
destination = c;
break;
}
}
transport.QueueActivity(new Land(transport, Target.FromCell(transport.World, destination), facing: aircraft.Info.InitialFacing));
transport.QueueActivity(new Wait(15));
}
transport.QueueActivity(new Land(transport, Target.FromCell(transport.World, entryPath.Last()), WDist.FromCells(dropRange), aircraft.Info.InitialFacing));
if (cargo != null)
{
transport.QueueActivity(new UnloadCargo(transport, true));
transport.QueueActivity(new WaitFor(() => cargo.IsEmpty(transport)));
}
transport.QueueActivity(new Wait(aircraft != null ? 50 : 25));
transport.QueueActivity(new UnloadCargo(transport, WDist.FromCells(dropRange)));
}
if (exitFunc != null)