fetch the max range from AttackBaseInfo rather than making it up completely

This commit is contained in:
Chris Forbes
2011-02-08 18:25:51 +13:00
parent 3369373879
commit b0beee6b7b
2 changed files with 11 additions and 2 deletions

View File

@@ -38,6 +38,14 @@ namespace OpenRA.Mods.RA
public readonly float ScanTimeSpread = .5f; public readonly float ScanTimeSpread = .5f;
public abstract object Create(ActorInitializer init); public abstract object Create(ActorInitializer init);
public float GetMaximumRange()
{
var priRange = PrimaryWeapon != null ? Rules.Weapons[PrimaryWeapon.ToLowerInvariant()].Range : 0;
var secRange = SecondaryWeapon != null ? Rules.Weapons[SecondaryWeapon.ToLowerInvariant()].Range : 0;
return Math.Max(priRange, secRange);
}
} }
public abstract class AttackBase : IIssueOrder, IResolveOrder, ITick, IExplodeModifier, IOrderVoice, ISync public abstract class AttackBase : IIssueOrder, IResolveOrder, ITick, IExplodeModifier, IOrderVoice, ISync

View File

@@ -21,13 +21,14 @@ namespace OpenRA.Mods.RA
class RenderRangeCircleInfo : TraitInfo<RenderRangeCircle>, IPlaceBuildingDecoration class RenderRangeCircleInfo : TraitInfo<RenderRangeCircle>, IPlaceBuildingDecoration
{ {
public readonly string RangeCircleType; //public readonly string RangeCircleType;
public void Render(WorldRenderer wr, World w, ActorInfo ai, int2 centerLocation) public void Render(WorldRenderer wr, World w, ActorInfo ai, int2 centerLocation)
{ {
wr.DrawRangeCircle( wr.DrawRangeCircle(
Color.FromArgb(128, Color.Yellow), Color.FromArgb(128, Color.Yellow),
centerLocation, 3 /* hack: get this from the ActorInfo, but it's nontrivial currently */); centerLocation,
ai.Traits.Get<AttackBaseInfo>().GetMaximumRange());
} }
} }