adding new ai functional

This commit is contained in:
Matthias Mailänder
2013-03-06 11:17:02 +01:00
parent 3f56e00173
commit e0b7242f1b
15 changed files with 1722 additions and 177 deletions

View File

@@ -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;