PathSearch, make TargetPredicate a readonly private field.

This commit is contained in:
Vapre
2022-07-03 12:57:37 +02:00
committed by abcdefg30
parent 834de4efbe
commit 8c042a243e

View File

@@ -115,7 +115,7 @@ namespace OpenRA.Mods.Common.Pathfinder
public IPathGraph Graph { get; } public IPathGraph Graph { get; }
readonly Func<CPos, int> heuristic; readonly Func<CPos, int> heuristic;
readonly int heuristicWeightPercentage; readonly int heuristicWeightPercentage;
public Func<CPos, bool> TargetPredicate { get; set; } readonly Func<CPos, bool> targetPredicate;
readonly IPriorityQueue<GraphConnection> openQueue; readonly IPriorityQueue<GraphConnection> openQueue;
/// <summary> /// <summary>
@@ -137,7 +137,7 @@ namespace OpenRA.Mods.Common.Pathfinder
Graph = graph; Graph = graph;
this.heuristic = heuristic; this.heuristic = heuristic;
this.heuristicWeightPercentage = heuristicWeightPercentage; this.heuristicWeightPercentage = heuristicWeightPercentage;
TargetPredicate = targetPredicate; this.targetPredicate = targetPredicate;
openQueue = new PriorityQueue<GraphConnection>(GraphConnection.ConnectionCostComparer); openQueue = new PriorityQueue<GraphConnection>(GraphConnection.ConnectionCostComparer);
} }
@@ -224,7 +224,7 @@ namespace OpenRA.Mods.Common.Pathfinder
while (CanExpand()) while (CanExpand())
{ {
var p = Expand(); var p = Expand();
if (TargetPredicate(p)) if (targetPredicate(p))
return MakePath(Graph, p); return MakePath(Graph, p);
} }