diff --git a/OpenRA.Mods.Common/Pathfinder/BasePathSearch.cs b/OpenRA.Mods.Common/Pathfinder/BasePathSearch.cs index 13c8c0e79d..8fba8f3e09 100644 --- a/OpenRA.Mods.Common/Pathfinder/BasePathSearch.cs +++ b/OpenRA.Mods.Common/Pathfinder/BasePathSearch.cs @@ -23,11 +23,6 @@ namespace OpenRA.Mods.Common.Pathfinder /// IGraph Graph { get; } - /// - /// The open queue where nodes that are worth to consider are stored by their estimator - /// - IPriorityQueue OpenQueue { get; } - /// /// Stores the analyzed nodes by the expand function /// @@ -62,6 +57,7 @@ namespace OpenRA.Mods.Common.Pathfinder /// Whether the location is a target bool IsTarget(CPos location); + bool CanExpand { get; } CPos Expand(); } @@ -69,7 +65,7 @@ namespace OpenRA.Mods.Common.Pathfinder { public IGraph Graph { get; set; } - public IPriorityQueue OpenQueue { get; protected set; } + protected IPriorityQueue OpenQueue { get; private set; } public abstract IEnumerable> Considered { get; } @@ -84,7 +80,7 @@ namespace OpenRA.Mods.Common.Pathfinder // points considered and their Heuristics to reach // the target. It pretty match identifies, in conjunction of the Actor, // a deterministic set of calculations - protected IPriorityQueue startPoints; + protected readonly IPriorityQueue startPoints; protected BasePathSearch(IGraph graph) { @@ -165,6 +161,7 @@ namespace OpenRA.Mods.Common.Pathfinder return isGoal(location); } + public bool CanExpand { get { return !OpenQueue.Empty; } } public abstract CPos Expand(); } } diff --git a/OpenRA.Mods.Common/Traits/World/PathFinder.cs b/OpenRA.Mods.Common/Traits/World/PathFinder.cs index 6524d67775..405f2b2a28 100644 --- a/OpenRA.Mods.Common/Traits/World/PathFinder.cs +++ b/OpenRA.Mods.Common/Traits/World/PathFinder.cs @@ -121,7 +121,7 @@ namespace OpenRA.Mods.Common.Traits List path = null; - while (!search.OpenQueue.Empty) + while (search.CanExpand) { var p = search.Expand(); if (search.IsTarget(p)) @@ -156,7 +156,7 @@ namespace OpenRA.Mods.Common.Traits fromDest.Debug = true; } - while (!fromSrc.OpenQueue.Empty && !fromDest.OpenQueue.Empty) + while (fromSrc.CanExpand && fromDest.CanExpand) { // make some progress on the first search var p = fromSrc.Expand();