2757bf3a3b
Split VoxelWorld nav contracts into focused files and extract clustered coverage helpers so the navmesh service stays a coordinator instead of a catch-all runtime file.
58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using System;
|
|
using InfiniteWorld.VoxelWorld.Contracts;
|
|
using UnityEngine;
|
|
using UnityEngine.AI;
|
|
using UnityNavMesh = UnityEngine.AI.NavMesh;
|
|
using UnityNavMeshBuilder = UnityEngine.AI.NavMeshBuilder;
|
|
|
|
namespace InfiniteWorld.VoxelWorld.NavMesh
|
|
{
|
|
internal sealed class NavCoverageWindowRuntime : IDisposable
|
|
{
|
|
public NavCoverageWindowRuntime(int id, Bounds coverageBounds, float priority, int interestCount)
|
|
{
|
|
Id = id;
|
|
CoverageBounds = coverageBounds;
|
|
Priority = priority;
|
|
InterestCount = interestCount;
|
|
State = NavCoverageState.Pending;
|
|
}
|
|
|
|
public int Id { get; }
|
|
public Bounds CoverageBounds;
|
|
public Bounds CollectionBounds;
|
|
public Bounds BuildBounds;
|
|
public float Priority;
|
|
public int InterestCount;
|
|
public NavCoverageState State;
|
|
public NavMeshData NavMeshData;
|
|
public NavMeshDataInstance Instance;
|
|
public AsyncOperation ActiveBuild;
|
|
public bool BuildRequestedWhileRunning;
|
|
public bool MatchedThisFrame;
|
|
|
|
public void ResetCoverageData()
|
|
{
|
|
if (ActiveBuild != null && !ActiveBuild.isDone && NavMeshData != null)
|
|
{
|
|
UnityNavMeshBuilder.Cancel(NavMeshData);
|
|
}
|
|
|
|
if (Instance.valid)
|
|
{
|
|
UnityNavMesh.RemoveNavMeshData(Instance);
|
|
Instance = default;
|
|
}
|
|
|
|
ActiveBuild = null;
|
|
NavMeshData = null;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
ResetCoverageData();
|
|
State = NavCoverageState.Pending;
|
|
}
|
|
}
|
|
}
|