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:
RoosterDragon
2022-04-18 20:31:51 +01:00
committed by Matthias Mailänder
parent 5a8f91aa21
commit aef65d353d
15 changed files with 130 additions and 283 deletions

View File

@@ -17,7 +17,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[TraitLocation(SystemActors.World)]
public class ElevatedBridgeLayerInfo : TraitInfo, Requires<DomainIndexInfo>, ILobbyCustomRulesIgnore, ICustomMovementLayerInfo
public class ElevatedBridgeLayerInfo : TraitInfo, ILobbyCustomRulesIgnore, ICustomMovementLayerInfo
{
[Desc("Terrain type used by cells outside any elevated bridge footprint.")]
public readonly string ImpassableTerrainType = "Impassable";
@@ -44,7 +44,6 @@ namespace OpenRA.Mods.Common.Traits
public void WorldLoaded(World world, WorldRenderer wr)
{
var domainIndex = world.WorldActor.Trait<DomainIndex>();
var cellHeight = world.Map.CellHeightStep.Length;
foreach (var tti in world.WorldActor.Info.TraitInfos<ElevatedBridgePlaceholderInfo>())
{
@@ -61,7 +60,6 @@ namespace OpenRA.Mods.Common.Traits
}
var end = tti.EndCells();
domainIndex.AddFixedConnection(end);
foreach (var c in end)
{
// Need to explicitly set both default and tunnel layers, otherwise the .Contains check will fail