Pathing considers reachability of source cells consistently.

Using the local pathfinder, you could not find a path to an unreachable destination cell, but it was possible to find a path from an unreachable source cell if there was a reachable cells adjacent to it.

The hierarchical pathfinder did not have this behaviour and considering an unreachable source cell to block attempts to find a path.

Now, we unify the pathfinders to use a consistent behaviour, allowing paths from unreachable source cells to be found.
This commit is contained in:
RoosterDragon
2022-10-25 20:23:53 +01:00
committed by abcdefg30
parent bedfa622d7
commit a85ac26367
6 changed files with 145 additions and 60 deletions

View File

@@ -76,11 +76,17 @@ namespace OpenRA.Mods.Common.Pathfinder
return search;
}
public static bool CellAllowsMovement(World world, Locomotor locomotor, CPos cell, Func<CPos, int> customCost)
{
return world.Map.Contains(cell) &&
(cell.Layer == 0 || world.GetCustomMovementLayers()[cell.Layer].EnabledForLocomotor(locomotor.Info)) &&
(customCost == null || customCost(cell) != PathGraph.PathCostForInvalidPath);
}
static void AddInitialCells(World world, Locomotor locomotor, IEnumerable<CPos> froms, Func<CPos, int> customCost, PathSearch search)
{
var customMovementLayers = world.GetCustomMovementLayers();
foreach (var sl in froms)
if (world.Map.Contains(sl) && (sl.Layer == 0 || customMovementLayers[sl.Layer].EnabledForLocomotor(locomotor.Info)))
if (CellAllowsMovement(world, locomotor, sl, customCost))
search.AddInitialCell(sl, customCost);
}