adding new ai functional
This commit is contained in:
@@ -229,7 +229,22 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
public CPos NearestMoveableCell(CPos target, int minRange, int maxRange)
|
||||
{
|
||||
return NearestCell(target, CanEnterCell, minRange, maxRange);
|
||||
if (CanEnterCell(target))
|
||||
return target;
|
||||
|
||||
var searched = new List<CPos>();
|
||||
// Limit search to a radius of 10 tiles
|
||||
for (int r = minRange; r < maxRange; r++)
|
||||
foreach (var tile in self.World.FindTilesInCircle(target, r).Except(searched))
|
||||
{
|
||||
if (CanEnterCell(tile))
|
||||
return tile;
|
||||
|
||||
searched.Add(tile);
|
||||
}
|
||||
|
||||
// Couldn't find a cell
|
||||
return target;
|
||||
}
|
||||
|
||||
public CPos NearestCell(CPos target, Func<CPos, bool> check, int minRange, int maxRange)
|
||||
@@ -237,9 +252,15 @@ namespace OpenRA.Mods.RA.Move
|
||||
if (check(target))
|
||||
return target;
|
||||
|
||||
foreach (var tile in self.World.FindTilesInCircle(target, maxRange))
|
||||
if (check(tile))
|
||||
return tile;
|
||||
var searched = new List<CPos>();
|
||||
for (int r = minRange; r < maxRange; r++)
|
||||
foreach (var tile in self.World.FindTilesInCircle(target, r).Except(searched))
|
||||
{
|
||||
if (check(tile))
|
||||
return tile;
|
||||
|
||||
searched.Add(tile);
|
||||
}
|
||||
|
||||
// Couldn't find a cell
|
||||
return target;
|
||||
|
||||
Reference in New Issue
Block a user