Don't pass movement class via IsPassable directly

Let IsPassable get that info from the locomotor instead.
This commit is contained in:
reaperrr
2018-03-23 23:47:03 +01:00
committed by abcdefg30
parent a52e83ca49
commit 5364515004
9 changed files with 25 additions and 35 deletions

View File

@@ -159,22 +159,19 @@ namespace OpenRA.Mods.Common.Scripting
// Try to find an alternative landing spot if we can't land at the current destination
if (!aircraft.CanLand(destination) && dropRange > 0)
{
var mobiles = cargo != null ? cargo.Passengers.Select(a =>
{
var mobile = a.TraitOrDefault<Mobile>();
if (mobile == null)
return new Pair<LocomotorInfo, uint>(null, 0);
var locomotorInfo = mobile.Info.LocomotorInfo;
return new Pair<LocomotorInfo, uint>(locomotorInfo, (uint)locomotorInfo.GetMovementClass(a.World.Map.Rules.TileSet));
}) : new Pair<LocomotorInfo, uint>[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 (!mobiles.All(m => m.First == null || domainIndex.IsPassable(destination, c, m.First, m.Second)))
if (!locomotors.All(m => domainIndex.IsPassable(destination, c, m)))
continue;
destination = c;