fixed #999 -- replace order/first[ordefault] with .ClosestTo(point)

This commit is contained in:
Chris Forbes
2011-07-08 23:01:05 +12:00
committed by Paul Chote
parent 5c3a6c81ae
commit e44b965785
7 changed files with 18 additions and 18 deletions

View File

@@ -32,15 +32,13 @@ namespace OpenRA.Mods.RA.Activities
var buildings = self.Info.Traits.Get<MinelayerInfo>().RearmBuildings;
var rearmTarget = self.World.Actors.Where(a => a.Owner != null && self.Owner.Stances[a.Owner] == Stance.Ally
&& buildings.Contains(a.Info.Name))
.OrderBy( a => (a.Location - self.Location).LengthSquared )
.FirstOrDefault();
.ClosestTo( self.CenterLocation );
if (rearmTarget == null)
return new Wait(20);
return Util.SequenceActivities(
new Enter(rearmTarget),
//new Move(Util.CellContaining(rearmTarget.CenterLocation), rearmTarget),
new Rearm(self),
new Repair(rearmTarget),
this );