diff --git a/OpenRA.Mods.RA/RenderRangeCircle.cs b/OpenRA.Mods.RA/RenderRangeCircle.cs index 53314bdcdf..6ea99cdbd2 100644 --- a/OpenRA.Mods.RA/RenderRangeCircle.cs +++ b/OpenRA.Mods.RA/RenderRangeCircle.cs @@ -10,6 +10,7 @@ using System.Drawing; using System.Linq; +using OpenRA.FileFormats; using OpenRA.Graphics; using OpenRA.Traits; @@ -20,15 +21,23 @@ namespace OpenRA.Mods.RA void Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition); } - class RenderRangeCircleInfo : ITraitInfo, IPlaceBuildingDecoration + class RenderRangeCircleInfo : ITraitInfo, IPlaceBuildingDecoration, Requires { public readonly string RangeCircleType = null; + [Desc("Range to draw if no armaments are available")] + public readonly WRange FallbackRange = WRange.Zero; + public void Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition) { - var range = ai.Traits.WithInterface() - .Select(a => Rules.Weapons[a.Weapon.ToLowerInvariant()].Range) - .Max(); + var armaments = ai.Traits.WithInterface(); + var range = FallbackRange; + + if (armaments.Any()) + range = armaments.Select(a => Rules.Weapons[a.Weapon.ToLowerInvariant()].Range).Max(); + + if (range == WRange.Zero) + return; wr.DrawRangeCircleWithContrast( centerPosition, @@ -49,8 +58,13 @@ namespace OpenRA.Mods.RA class RenderRangeCircle : IPostRenderSelection { Actor self; + AttackBase attack; - public RenderRangeCircle(Actor self) { this.self = self; } + public RenderRangeCircle(Actor self) + { + this.self = self; + attack = self.Trait(); + } public void RenderAfterWorld(WorldRenderer wr) { @@ -59,7 +73,7 @@ namespace OpenRA.Mods.RA wr.DrawRangeCircleWithContrast( self.CenterPosition, - self.Trait().GetMaximumRange(), + attack.GetMaximumRange(), Color.FromArgb(128, Color.Yellow), Color.FromArgb(96, Color.Black) );