Files
TheDeclineOfWarriors/Assets/Scripts/VoxelWorld/SceneWorldInterestReader.cs
T
Alexander Borisov 0b380def78 refactor nav coverage into clustered windows
Replace region-based runtime pathing with interest-cluster coverage windows so active nav areas stay contiguous and spawn anchors participate in initial coverage.
2026-04-08 13:52:00 +03:00

60 lines
1.7 KiB
C#

using System.Collections.Generic;
using InfiniteWorld.VoxelWorld;
using InfiniteWorld.VoxelWorld.Contracts;
using UnityEngine;
namespace VoxelWorldScene
{
public sealed class SceneWorldInterestReader : IWorldInterestReader
{
private readonly VoxelWorldGenerator worldGenerator;
private VoxelWorldSpawnAnchor[] spawnAnchors;
private int lastAnchorRefreshFrame = -1;
public SceneWorldInterestReader(VoxelWorldGenerator worldGenerator)
{
this.worldGenerator = worldGenerator;
}
public int InterestVersion => worldGenerator != null ? worldGenerator.InterestVersion : 0;
public void GetInterestPoints(List<WorldInterestPoint> results)
{
if (results == null)
{
return;
}
worldGenerator?.GetInterestPoints(results);
RefreshSpawnAnchors();
if (spawnAnchors == null)
{
return;
}
for (int i = 0; i < spawnAnchors.Length; i++)
{
VoxelWorldSpawnAnchor anchor = spawnAnchors[i];
if (anchor == null || !anchor.isActiveAndEnabled)
{
continue;
}
results.Add(new WorldInterestPoint(anchor.transform.position, anchor.Priority, WorldInterestKind.SpawnAnchor));
}
}
private void RefreshSpawnAnchors()
{
if (lastAnchorRefreshFrame == Time.frameCount)
{
return;
}
lastAnchorRefreshFrame = Time.frameCount;
spawnAnchors = Object.FindObjectsByType<VoxelWorldSpawnAnchor>(FindObjectsInactive.Exclude, FindObjectsSortMode.None);
}
}
}