Shift Actor.Health onto a trait.

Known regressions:
 - cnc only
 - health bar colors
 - can't repair buildings
This commit is contained in:
Paul Chote
2010-07-30 00:01:59 +12:00
parent 1e08dc6301
commit 6fba888d45
56 changed files with 530 additions and 303 deletions

View File

@@ -37,8 +37,9 @@ namespace OpenRA.Mods.RA
return true; // he's dead.
if ((attack.target.CenterLocation - self.Location).LengthSquared > range * range + 2)
return true; // wandered off faster than we could follow
if (attack.target.IsActor && attack.target.Actor.Health
== attack.target.Actor.Info.Traits.Get<OwnedActorInfo>().HP)
var health = attack.target.Actor.traits.GetOrDefault<Health>();
if (attack.target.IsActor && health.HP == health.MaxHP)
return true; // fully healed
return false;
@@ -59,7 +60,7 @@ namespace OpenRA.Mods.RA
return inRange
.Where(a => a != self && self.Owner.Stances[ a.Owner ] == Stance.Ally)
.Where(a => Combat.HasAnyValidWeapons(self, Target.FromActor(a)))
.Where(a => a.Health < a.Info.Traits.Get<OwnedActorInfo>().HP)
.Where(a => a.traits.Contains<Health>() && a.traits.Get<Health>().HPFraction < 1f)
.OrderBy(a => (a.Location - self.Location).LengthSquared)
.FirstOrDefault();
}