migrating most things to use the Target struct rather than Actor directly.

This commit is contained in:
Chris Forbes
2010-07-05 18:25:10 +12:00
parent 88b705c8ef
commit 5c61c9d3a9
14 changed files with 57 additions and 49 deletions

View File

@@ -40,8 +40,8 @@ namespace OpenRA.Mods.RA
var attack = self.traits.Get<AttackBase>();
var range = Combat.GetMaximumRange(self);
if (attack.target == null ||
(attack.target.Location - self.Location).LengthSquared > range * range)
if (!attack.target.IsValid ||
(Util.CellContaining(attack.target.CenterLocation) - self.Location).LengthSquared > range * range)
AttackTarget(self, ChooseTarget(self, range));
var info = self.Info.Traits.Get<AutoTargetInfo>();
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.RA
return inRange
.Where(a => a.Owner != null && self.Owner.Stances[ a.Owner ] == Stance.Enemy)
.Where(a => Combat.HasAnyValidWeapons(self, a))
.Where(a => Combat.HasAnyValidWeapons(self, Target.FromActor(a)))
.Where(a => !a.traits.Contains<Cloak>() || !a.traits.Get<Cloak>().Cloaked)
.OrderBy(a => (a.Location - self.Location).LengthSquared)
.FirstOrDefault();
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.RA
if (!e.Attacker.Info.Traits.Contains<OwnedActorInfo>()) return;
// not a lot we can do about things we can't hurt... although maybe we should automatically run away?
if (!Combat.HasAnyValidWeapons(self, e.Attacker)) return;
if (!Combat.HasAnyValidWeapons(self, Target.FromActor(e.Attacker))) return;
// don't retaliate against own units force-firing on us. it's usually not what the player wanted.
if (self.Owner.Stances[e.Attacker.Owner] == Stance.Ally) return;