move Selectable.Radius into Health
This commit is contained in:
@@ -22,6 +22,7 @@ namespace OpenRA.Traits
|
|||||||
public class HealthInfo : ITraitInfo
|
public class HealthInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public readonly int HP = 0;
|
public readonly int HP = 0;
|
||||||
|
public readonly float Radius = 10;
|
||||||
public virtual object Create(ActorInitializer init) { return new Health(init, this); }
|
public virtual object Create(ActorInitializer init) { return new Health(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ namespace OpenRA.Traits
|
|||||||
public readonly int[] Bounds = null;
|
public readonly int[] Bounds = null;
|
||||||
[VoiceReference]
|
[VoiceReference]
|
||||||
public readonly string Voice = null;
|
public readonly string Voice = null;
|
||||||
public readonly float Radius = 10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Selectable : IPostRenderSelection
|
public class Selectable : IPostRenderSelection
|
||||||
|
|||||||
@@ -151,9 +151,10 @@ namespace OpenRA.Mods.RA
|
|||||||
// don't hit air units with splash from ground explosions, etc
|
// don't hit air units with splash from ground explosions, etc
|
||||||
if (!WeaponValidForTarget(args.weapon, target)) return 0f;
|
if (!WeaponValidForTarget(args.weapon, target)) return 0f;
|
||||||
|
|
||||||
var selectable = target.Info.Traits.GetOrDefault<SelectableInfo>();
|
var health = target.Info.Traits.GetOrDefault<HealthInfo>();
|
||||||
var radius = selectable != null ? selectable.Radius : 0;
|
if( health == null ) return 0f;
|
||||||
var distance = (int)Math.Max(0, (target.CenterLocation - args.dest).Length - radius);
|
|
||||||
|
var distance = (int)Math.Max(0, (target.CenterLocation - args.dest).Length - health.Radius);
|
||||||
var falloff = (float)GetDamageFalloff(distance / warhead.Spread);
|
var falloff = (float)GetDamageFalloff(distance / warhead.Spread);
|
||||||
var rawDamage = (float)(warhead.Damage * modifier * falloff);
|
var rawDamage = (float)(warhead.Damage * modifier * falloff);
|
||||||
var multiplier = (float)warhead.EffectivenessAgainst(target);
|
var multiplier = (float)warhead.EffectivenessAgainst(target);
|
||||||
|
|||||||
Reference in New Issue
Block a user