Rename PathGraph to MapPathGraph.

Move PathCostForInvalidPath and MovementCostForUnreachableCell constants into a new static class, PathGraph.
This commit is contained in:
RoosterDragon
2022-04-23 13:32:57 +01:00
committed by abcdefg30
parent a1a583ea0a
commit e22b6de4e8
3 changed files with 10 additions and 7 deletions

View File

@@ -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;
}
/// <summary>
/// Represents part of an edge in a graph, giving the cost to traverse to a node.
/// </summary>

View File

@@ -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 <see cref="ICustomMovementLayer"/>.
/// </summary>
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<CellInfo>[] 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<CPos, int> customCost, Actor ignoreActor, bool laneBias, bool inReverse)
: base(locomotor, actor, world, check, customCost, ignoreActor, laneBias, inReverse)
{

View File

@@ -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<CPos, int> 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);