Change EffectivenessAgainst to CanTargetActor.

This commit is contained in:
Paul Chote
2014-08-17 19:41:22 +12:00
parent 227a523878
commit d002a23d67
2 changed files with 12 additions and 10 deletions

View File

@@ -56,13 +56,15 @@ namespace OpenRA.GameRules
return 100; return 100;
} }
public override int EffectivenessAgainst(ActorInfo ai) // TODO: This can be removed after the legacy and redundant 0% = not targetable
// assumption has been removed from the yaml definitions
public override bool CanTargetActor(ActorInfo victim, Actor firedBy)
{ {
var health = ai.Traits.GetOrDefault<HealthInfo>(); var health = victim.Traits.GetOrDefault<HealthInfo>();
if (health == null) if (health == null)
return 0; return false;
return DamageVersus(ai); return DamageVersus(victim) > 0;
} }
public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers) public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers)

View File

@@ -29,8 +29,6 @@ namespace OpenRA.GameRules
public abstract void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers); public abstract void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers);
public virtual int EffectivenessAgainst(ActorInfo ai) { return 0; }
public bool IsValidAgainst(Target target, World world, Actor firedBy) public bool IsValidAgainst(Target target, World world, Actor firedBy)
{ {
if (target.Type == TargetType.Actor) if (target.Type == TargetType.Actor)
@@ -56,10 +54,13 @@ namespace OpenRA.GameRules
return false; return false;
} }
// TODO: This can be removed after the legacy and redundant 0% = not targetable
// assumption has been removed from the yaml definitions
public virtual bool CanTargetActor(ActorInfo victim, Actor firedBy) { return false; }
public bool IsValidAgainst(Actor victim, Actor firedBy) public bool IsValidAgainst(Actor victim, Actor firedBy)
{ {
// If this warhead is ineffective against the target, then it is not a valid target if (!CanTargetActor(victim.Info, firedBy))
if (EffectivenessAgainst(victim.Info) <= 0)
return false; return false;
// A target type is valid if it is in the valid targets list, and not in the invalid targets list. // A target type is valid if it is in the valid targets list, and not in the invalid targets list.
@@ -83,8 +84,7 @@ namespace OpenRA.GameRules
public bool IsValidAgainst(FrozenActor victim, Actor firedBy) public bool IsValidAgainst(FrozenActor victim, Actor firedBy)
{ {
// If this warhead is ineffective against the target, then it is not a valid target if (!CanTargetActor(victim.Info, firedBy))
if (EffectivenessAgainst(victim.Info) <= 0)
return false; return false;
// A target type is valid if it is in the valid targets list, and not in the invalid targets list. // A target type is valid if it is in the valid targets list, and not in the invalid targets list.