reorganize navmesh contracts and services
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.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user