customBlocker support in PathSearch; local unit avoidance in normal unit pathing
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user