Ensure a valid target in move.

This commit is contained in:
Paul Chote
2013-07-07 11:14:25 +12:00
parent 87361df043
commit 8fe0eb73e2

View File

@@ -58,11 +58,18 @@ namespace OpenRA.Mods.RA.Move
this.ignoreBuilding = ignoreBuilding;
}
static readonly List<CPos> NoPath = new List<CPos>();
public Move(Target target, int range)
{
this.getPath = (self,mobile) => self.World.WorldActor.Trait<PathFinder>().FindUnitPathToRange(
mobile.toCell, target.CenterPosition.ToCPos(),
range, self);
this.getPath = (self, mobile) =>
{
if (!target.IsValid)
return NoPath;
return self.World.WorldActor.Trait<PathFinder>().FindUnitPathToRange(
mobile.toCell, target.CenterPosition.ToCPos(), range, self);
};
this.destination = null;
this.nearEnough = range;
}