customBlocker support in PathSearch; local unit avoidance in normal unit pathing

This commit is contained in:
Chris Forbes
2009-11-09 15:02:49 +13:00
parent 55adc19aa9
commit 651399ed19
2 changed files with 16 additions and 12 deletions

View File

@@ -13,6 +13,7 @@ namespace OpenRa.Game
public PriorityQueue<PathDistance> queue;
public Func<int2, float> heuristic;
public UnitMovementType umt;
Func<int2, bool> customBlock;
public bool checkForBlocked;
public PathSearch()
@@ -21,6 +22,12 @@ namespace OpenRa.Game
queue = new PriorityQueue<PathDistance>();
}
public PathSearch WithCustomBlocker(Func<int2, bool> customBlock)
{
this.customBlock = customBlock;
return this;
}
public int2 Expand( float[][ , ] passableCost )
{
var p = queue.Pop();
@@ -38,6 +45,9 @@ namespace OpenRa.Game
continue;
if( checkForBlocked && Game.UnitInfluence.GetUnitAt( newHere ) != null )
continue;
if (customBlock != null && customBlock(newHere))
continue;
var est = heuristic( newHere );
if( est == float.PositiveInfinity )
continue;