From 9a2cdcde116cc697023c748688ff76c863d3c715 Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 6 Nov 2010 14:35:26 +1300 Subject: [PATCH] move Selectable.Radius into Health --- OpenRA.Game/Traits/Health.cs | 1 + OpenRA.Game/Traits/Selectable.cs | 1 - OpenRA.Mods.RA/Combat.cs | 7 ++++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/OpenRA.Game/Traits/Health.cs b/OpenRA.Game/Traits/Health.cs index 7bcfdbd295..9016815c7c 100755 --- a/OpenRA.Game/Traits/Health.cs +++ b/OpenRA.Game/Traits/Health.cs @@ -22,6 +22,7 @@ namespace OpenRA.Traits public class HealthInfo : ITraitInfo { public readonly int HP = 0; + public readonly float Radius = 10; public virtual object Create(ActorInitializer init) { return new Health(init, this); } } diff --git a/OpenRA.Game/Traits/Selectable.cs b/OpenRA.Game/Traits/Selectable.cs index 3798ec31b4..8d82da0d6d 100644 --- a/OpenRA.Game/Traits/Selectable.cs +++ b/OpenRA.Game/Traits/Selectable.cs @@ -19,7 +19,6 @@ namespace OpenRA.Traits public readonly int[] Bounds = null; [VoiceReference] public readonly string Voice = null; - public readonly float Radius = 10; } public class Selectable : IPostRenderSelection diff --git a/OpenRA.Mods.RA/Combat.cs b/OpenRA.Mods.RA/Combat.cs index e0e8f3c766..064728cdcf 100755 --- a/OpenRA.Mods.RA/Combat.cs +++ b/OpenRA.Mods.RA/Combat.cs @@ -151,9 +151,10 @@ namespace OpenRA.Mods.RA // don't hit air units with splash from ground explosions, etc if (!WeaponValidForTarget(args.weapon, target)) return 0f; - var selectable = target.Info.Traits.GetOrDefault(); - var radius = selectable != null ? selectable.Radius : 0; - var distance = (int)Math.Max(0, (target.CenterLocation - args.dest).Length - radius); + var health = target.Info.Traits.GetOrDefault(); + if( health == null ) return 0f; + + var distance = (int)Math.Max(0, (target.CenterLocation - args.dest).Length - health.Radius); var falloff = (float)GetDamageFalloff(distance / warhead.Spread); var rawDamage = (float)(warhead.Damage * modifier * falloff); var multiplier = (float)warhead.EffectivenessAgainst(target);