Replace DomainIndex internals with a lookup from HierarchicalPathFinder instead
Teach HierarchicalPathFinder to keep a cache of domain indices, refreshing them only on demand and when invalidated by terrain changes. This provides an accurate and quick determination for checking if paths exist between given locations. By exposing PathExistsForLocomotor on the IPathFinder interface, we can remove the DomainIndex trait entirely.
This commit is contained in:
committed by
Matthias Mailänder
parent
5a8f91aa21
commit
aef65d353d
@@ -88,10 +88,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
: new[] { Locomotor };
|
||||
foreach (var locomotor in locomotors)
|
||||
{
|
||||
var abstractGraph = pathFinder.GetOverlayDataForLocomotor(locomotor);
|
||||
var (abstractGraph, abstractDomains) = pathFinder.GetOverlayDataForLocomotor(locomotor);
|
||||
|
||||
// Locomotor doesn't allow movement, nothing to display.
|
||||
if (abstractGraph == null)
|
||||
if (abstractGraph == null || abstractDomains == null)
|
||||
continue;
|
||||
|
||||
foreach (var connectionsFromOneNode in abstractGraph)
|
||||
@@ -129,6 +129,19 @@ namespace OpenRA.Mods.Common.Traits
|
||||
yield return new TextAnnotationRenderable(font, centerPos, 0, lineColor, cost.Cost.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var domainForCell in abstractDomains)
|
||||
{
|
||||
var nodeCell = domainForCell.Key;
|
||||
var srcUv = (PPos)nodeCell.ToMPos(self.World.Map);
|
||||
if (!visibleRegion.Contains(srcUv))
|
||||
continue;
|
||||
|
||||
// Show the abstract cell and its domain index.
|
||||
var nodePos = self.World.Map.CenterOfSubCell(nodeCell, SubCell.FullCell);
|
||||
yield return new TextAnnotationRenderable(
|
||||
font, nodePos, 0, info.AbstractNodeColor, $"{domainForCell.Value}: {nodeCell}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user