add documentation
This commit is contained in:
@@ -7,6 +7,9 @@ using VContainer.Unity;
|
||||
|
||||
namespace InfiniteWorld.VoxelWorld.NavMesh
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores short-lived route hints and expands them into interest points so nav coverage can prewarm ahead of movement.
|
||||
/// </summary>
|
||||
public sealed class NavCoverageHintService : ITickable, INavCoverageHintRegistry, INavCoverageHintReader
|
||||
{
|
||||
private readonly IChunkNavSourceReader chunkNavSourceReader;
|
||||
@@ -27,8 +30,14 @@ namespace InfiniteWorld.VoxelWorld.NavMesh
|
||||
this.hintChangedPublisher = hintChangedPublisher;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increments whenever the effective set of active hints changes and cached coverage planning should be invalidated.
|
||||
/// </summary>
|
||||
public int HintVersion => hintVersion;
|
||||
|
||||
/// <summary>
|
||||
/// Expires hints whose time-to-live has elapsed so stale route bias does not keep shaping coverage forever.
|
||||
/// </summary>
|
||||
public void Tick()
|
||||
{
|
||||
if (hints.Count == 0)
|
||||
@@ -61,6 +70,9 @@ namespace InfiniteWorld.VoxelWorld.NavMesh
|
||||
NotifyHintsChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers or refreshes a temporary linear corridor for one owner so coverage can be biased along an upcoming route.
|
||||
/// </summary>
|
||||
public void SetLinearHint(int ownerId, Vector3 from, Vector3 to, float priority, float ttlSeconds)
|
||||
{
|
||||
if (ownerId == 0)
|
||||
@@ -74,6 +86,9 @@ namespace InfiniteWorld.VoxelWorld.NavMesh
|
||||
NotifyHintsChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a previously registered route hint once the owner no longer needs prewarmed coverage.
|
||||
/// </summary>
|
||||
public void ClearHint(int ownerId)
|
||||
{
|
||||
if (!hints.Remove(ownerId))
|
||||
@@ -84,6 +99,9 @@ namespace InfiniteWorld.VoxelWorld.NavMesh
|
||||
NotifyHintsChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends the currently active hint points so the main coverage scheduler can treat them like supplemental interest.
|
||||
/// </summary>
|
||||
public void GetHintPoints(List<WorldInterestPoint> results)
|
||||
{
|
||||
if (results == null)
|
||||
|
||||
@@ -4,6 +4,9 @@ using UnityEngine;
|
||||
namespace InfiniteWorld.VoxelWorld.NavMesh
|
||||
{
|
||||
[Serializable]
|
||||
/// <summary>
|
||||
/// Inspector-friendly tuning parameters that bound how clustered nav coverage is shaped and rebuilt at runtime.
|
||||
/// </summary>
|
||||
public sealed class VoxelWorldNavMeshConfig
|
||||
{
|
||||
[Min(0)] public int agentTypeId;
|
||||
|
||||
@@ -10,6 +10,9 @@ using UnityNavMeshBuilder = UnityEngine.AI.NavMeshBuilder;
|
||||
|
||||
namespace InfiniteWorld.VoxelWorld.NavMesh
|
||||
{
|
||||
/// <summary>
|
||||
/// Coordinates clustered runtime NavMesh coverage over the voxel world by rebuilding a bounded set of windows around active interest.
|
||||
/// </summary>
|
||||
public sealed class VoxelWorldNavMeshService : IStartable, ITickable, IDisposable, INavCoverageReader
|
||||
{
|
||||
private readonly IChunkNavSourceReader chunkNavSourceReader;
|
||||
@@ -54,6 +57,9 @@ namespace InfiniteWorld.VoxelWorld.NavMesh
|
||||
this.config = config ?? new VoxelWorldNavMeshConfig();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subscribes to world invalidation and primes the initial set of coverage windows for the current interest snapshot.
|
||||
/// </summary>
|
||||
public void Start()
|
||||
{
|
||||
subscriptions.Add(chunkReadySubscriber.Subscribe(OnChunkNavGeometryReady));
|
||||
@@ -66,6 +72,9 @@ namespace InfiniteWorld.VoxelWorld.NavMesh
|
||||
MarkAllCoverageWindowsDirty();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Advances the clustered coverage scheduler, refreshing interest and starting bounded asynchronous builds when needed.
|
||||
/// </summary>
|
||||
public void Tick()
|
||||
{
|
||||
RefreshInterestPoints();
|
||||
@@ -92,6 +101,9 @@ namespace InfiniteWorld.VoxelWorld.NavMesh
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the supplied world position is inside a ready coverage window and can be treated as nav-ready.
|
||||
/// </summary>
|
||||
public bool IsPositionCovered(Vector3 worldPosition)
|
||||
{
|
||||
foreach (KeyValuePair<int, NavCoverageWindowRuntime> pair in coverageWindows)
|
||||
@@ -106,6 +118,9 @@ namespace InfiniteWorld.VoxelWorld.NavMesh
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the current runtime coverage windows for diagnostics, readiness checks and higher-level planning.
|
||||
/// </summary>
|
||||
public void GetCoverageWindows(List<NavCoverageWindowSnapshot> results)
|
||||
{
|
||||
if (results == null)
|
||||
@@ -120,6 +135,9 @@ namespace InfiniteWorld.VoxelWorld.NavMesh
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases subscriptions and runtime NavMesh data owned by the service.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
for (int i = 0; i < subscriptions.Count; i++)
|
||||
|
||||
Reference in New Issue
Block a user