Merge pull request #9304 from atlimit8/Fix_AttackBase_GetMinimumRange
Make AttackBase.GetMinimumRange() return WDist.Zero if there are no available armaments
This commit is contained in:
@@ -27,6 +27,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public WDist(int r) { Length = r; }
|
public WDist(int r) { Length = r; }
|
||||||
public static readonly WDist Zero = new WDist(0);
|
public static readonly WDist Zero = new WDist(0);
|
||||||
|
public static readonly WDist MaxValue = new WDist(int.MaxValue);
|
||||||
public static WDist FromCells(int cells) { return new WDist(1024 * cells); }
|
public static WDist FromCells(int cells) { return new WDist(1024 * cells); }
|
||||||
|
|
||||||
public static WDist operator +(WDist a, WDist b) { return new WDist(a.Length + b.Length); }
|
public static WDist operator +(WDist a, WDist b) { return new WDist(a.Length + b.Length); }
|
||||||
|
|||||||
@@ -167,8 +167,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (IsTraitDisabled)
|
if (IsTraitDisabled)
|
||||||
return WDist.Zero;
|
return WDist.Zero;
|
||||||
|
|
||||||
return Armaments.Where(a => !a.IsTraitDisabled)
|
var min = Armaments.Where(a => !a.IsTraitDisabled)
|
||||||
.Select(a => a.Weapon.MinRange).Min();
|
.Select(a => a.Weapon.MinRange)
|
||||||
|
.Append(WDist.MaxValue).Min();
|
||||||
|
return min != WDist.MaxValue ? min : WDist.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WDist GetMaximumRange()
|
public WDist GetMaximumRange()
|
||||||
|
|||||||
Reference in New Issue
Block a user