diff --git a/OpenRA.Mods.Common/Pathfinder/PathSearch.cs b/OpenRA.Mods.Common/Pathfinder/PathSearch.cs index 9a57aa007c..84eee81d1b 100644 --- a/OpenRA.Mods.Common/Pathfinder/PathSearch.cs +++ b/OpenRA.Mods.Common/Pathfinder/PathSearch.cs @@ -46,9 +46,7 @@ namespace OpenRA.Mods.Common.Pathfinder var graph = new MapPathGraph(LayerPoolForWorld(world), locomotor, self, world, check, customCost, ignoreActor, laneBias, false); var search = new PathSearch(graph, loc => 0, 0, targetPredicate, recorder); - foreach (var sl in froms) - if (world.Map.Contains(sl)) - search.AddInitialCell(sl, customCost); + AddInitialCells(world, locomotor, froms, customCost, search); return search; } @@ -73,13 +71,19 @@ namespace OpenRA.Mods.Common.Pathfinder heuristic = heuristic ?? DefaultCostEstimator(locomotor, target); var search = new PathSearch(graph, heuristic, heuristicWeightPercentage, loc => loc == target, recorder); - foreach (var sl in froms) - if (world.Map.Contains(sl)) - search.AddInitialCell(sl, customCost); + AddInitialCells(world, locomotor, froms, customCost, search); return search; } + static void AddInitialCells(World world, Locomotor locomotor, IEnumerable froms, Func 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))) + search.AddInitialCell(sl, customCost); + } + public static PathSearch ToTargetCellOverGraph( Func> edges, Locomotor locomotor, CPos from, CPos target, int estimatedSearchSize = 0, IRecorder recorder = null)