Add an domain index check

This commit is contained in:
abcdefg30
2017-08-23 13:36:59 +02:00
committed by reaperrr
parent f48ba0ff86
commit 2366490fa0

View File

@@ -26,7 +26,13 @@ namespace OpenRA.Mods.Common.Scripting
[ScriptGlobal("Reinforcements")] [ScriptGlobal("Reinforcements")]
public class ReinforcementsGlobal : ScriptGlobal public class ReinforcementsGlobal : ScriptGlobal
{ {
public ReinforcementsGlobal(ScriptContext context) : base(context) { } readonly DomainIndex domainIndex;
public ReinforcementsGlobal(ScriptContext context)
: base(context)
{
domainIndex = context.World.WorldActor.Trait<DomainIndex>();
}
Actor CreateActor(Player owner, string actorType, bool addToWorld, CPos? entryLocation = null, CPos? nextLocation = null) Actor CreateActor(Player owner, string actorType, bool addToWorld, CPos? entryLocation = null, CPos? nextLocation = null)
{ {
@@ -153,11 +159,23 @@ namespace OpenRA.Mods.Common.Scripting
// Try to find an alternative landing spot if we can't land at the current destination // Try to find an alternative landing spot if we can't land at the current destination
if (!aircraft.CanLand(destination) && dropRange > 0) if (!aircraft.CanLand(destination) && dropRange > 0)
{ {
var mobiles = cargo != null ? cargo.Passengers.Select(a =>
{
var mobileInfo = a.Info.TraitInfoOrDefault<MobileInfo>();
if (mobileInfo == null)
return new Pair<MobileInfo, uint>(null, 0);
return new Pair<MobileInfo, uint>(mobileInfo, (uint)mobileInfo.GetMovementClass(a.World.Map.Rules.TileSet));
}) : new Pair<MobileInfo, uint>[0];
foreach (var c in transport.World.Map.FindTilesInCircle(destination, dropRange)) foreach (var c in transport.World.Map.FindTilesInCircle(destination, dropRange))
{ {
if (!aircraft.CanLand(c)) if (!aircraft.CanLand(c))
continue; continue;
if (!mobiles.All(m => m.First == null || domainIndex.IsPassable(destination, c, m.First, m.Second)))
continue;
destination = c; destination = c;
break; break;
} }