From e22b6de4e89c783b77697d6e0abd5aa0d5b455b2 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Sat, 23 Apr 2022 13:32:57 +0100 Subject: [PATCH] Rename PathGraph to MapPathGraph. Move PathCostForInvalidPath and MovementCostForUnreachableCell constants into a new static class, PathGraph. --- OpenRA.Mods.Common/Pathfinder/IPathGraph.cs | 6 ++++++ .../Pathfinder/{PathGraph.cs => MapPathGraph.cs} | 7 ++----- OpenRA.Mods.Common/Pathfinder/PathSearch.cs | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) rename OpenRA.Mods.Common/Pathfinder/{PathGraph.cs => MapPathGraph.cs} (86%) diff --git a/OpenRA.Mods.Common/Pathfinder/IPathGraph.cs b/OpenRA.Mods.Common/Pathfinder/IPathGraph.cs index 19715872be..87078a6402 100644 --- a/OpenRA.Mods.Common/Pathfinder/IPathGraph.cs +++ b/OpenRA.Mods.Common/Pathfinder/IPathGraph.cs @@ -32,6 +32,12 @@ namespace OpenRA.Mods.Common.Pathfinder CellInfo this[CPos node] { get; set; } } + public static class PathGraph + { + public const int PathCostForInvalidPath = int.MaxValue; + public const short MovementCostForUnreachableCell = short.MaxValue; + } + /// /// Represents part of an edge in a graph, giving the cost to traverse to a node. /// diff --git a/OpenRA.Mods.Common/Pathfinder/PathGraph.cs b/OpenRA.Mods.Common/Pathfinder/MapPathGraph.cs similarity index 86% rename from OpenRA.Mods.Common/Pathfinder/PathGraph.cs rename to OpenRA.Mods.Common/Pathfinder/MapPathGraph.cs index e500e65d35..f1197109c0 100644 --- a/OpenRA.Mods.Common/Pathfinder/PathGraph.cs +++ b/OpenRA.Mods.Common/Pathfinder/MapPathGraph.cs @@ -18,15 +18,12 @@ namespace OpenRA.Mods.Common.Pathfinder /// A dense pathfinding graph that supports a search over all cells within a map. /// It implements the ability to cost and get connections for cells, and supports . /// - sealed class PathGraph : DensePathGraph + sealed class MapPathGraph : DensePathGraph { - public const int PathCostForInvalidPath = int.MaxValue; - public const short MovementCostForUnreachableCell = short.MaxValue; - readonly CellInfoLayerPool.PooledCellInfoLayer pooledLayer; readonly CellLayer[] cellInfoForLayer; - public PathGraph(CellInfoLayerPool layerPool, Locomotor locomotor, Actor actor, World world, BlockedByActor check, + public MapPathGraph(CellInfoLayerPool layerPool, Locomotor locomotor, Actor actor, World world, BlockedByActor check, Func customCost, Actor ignoreActor, bool laneBias, bool inReverse) : base(locomotor, actor, world, check, customCost, ignoreActor, laneBias, inReverse) { diff --git a/OpenRA.Mods.Common/Pathfinder/PathSearch.cs b/OpenRA.Mods.Common/Pathfinder/PathSearch.cs index 95e768e433..5b5934e28b 100644 --- a/OpenRA.Mods.Common/Pathfinder/PathSearch.cs +++ b/OpenRA.Mods.Common/Pathfinder/PathSearch.cs @@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Pathfinder Actor ignoreActor = null, bool laneBias = true) { - var graph = new PathGraph(LayerPoolForWorld(world), locomotor, self, world, check, customCost, ignoreActor, laneBias, false); + var graph = new MapPathGraph(LayerPoolForWorld(world), locomotor, self, world, check, customCost, ignoreActor, laneBias, false); var search = new PathSearch(graph, loc => 0, DefaultHeuristicWeightPercentage, targetPredicate); foreach (var sl in froms) @@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Pathfinder Func heuristic = null, int heuristicWeightPercentage = DefaultHeuristicWeightPercentage) { - var graph = new PathGraph(LayerPoolForWorld(world), locomotor, self, world, check, customCost, ignoreActor, laneBias, inReverse); + var graph = new MapPathGraph(LayerPoolForWorld(world), locomotor, self, world, check, customCost, ignoreActor, laneBias, inReverse); heuristic = heuristic ?? DefaultCostEstimator(locomotor, target); var search = new PathSearch(graph, heuristic, heuristicWeightPercentage, loc => loc == target);