Ensure a valid target in move.
This commit is contained in:
@@ -58,11 +58,18 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
this.ignoreBuilding = ignoreBuilding;
|
this.ignoreBuilding = ignoreBuilding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static readonly List<CPos> NoPath = new List<CPos>();
|
||||||
public Move(Target target, int range)
|
public Move(Target target, int range)
|
||||||
{
|
{
|
||||||
this.getPath = (self,mobile) => self.World.WorldActor.Trait<PathFinder>().FindUnitPathToRange(
|
this.getPath = (self, mobile) =>
|
||||||
mobile.toCell, target.CenterPosition.ToCPos(),
|
{
|
||||||
range, self);
|
if (!target.IsValid)
|
||||||
|
return NoPath;
|
||||||
|
|
||||||
|
return self.World.WorldActor.Trait<PathFinder>().FindUnitPathToRange(
|
||||||
|
mobile.toCell, target.CenterPosition.ToCPos(), range, self);
|
||||||
|
};
|
||||||
|
|
||||||
this.destination = null;
|
this.destination = null;
|
||||||
this.nearEnough = range;
|
this.nearEnough = range;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user