using UnityEngine;
using UnityEngine.AI;
namespace InfiniteWorld.VoxelWorld.Contracts
{
///
/// Captures the nav-relevant state of one chunk at a specific version so sidecar systems can rebuild from immutable inputs.
///
public readonly struct ChunkNavSourceSnapshot
{
public ChunkNavSourceSnapshot(Vector2Int coord, int version, ChunkNavBuildSourceDescriptor[] sources)
{
Coord = coord;
Version = version;
Sources = sources;
}
///
/// Chunk coordinate this snapshot was produced for.
///
public Vector2Int Coord { get; }
///
/// Version of the chunk runtime state used to generate this snapshot.
///
public int Version { get; }
///
/// Stable nav build descriptors derived from the chunk's current geometry.
///
public ChunkNavBuildSourceDescriptor[] Sources { get; }
}
///
/// Describes one build source in a format that can be consumed without direct references to world internals or scene scans.
///
public readonly struct ChunkNavBuildSourceDescriptor
{
public ChunkNavBuildSourceDescriptor(NavMeshBuildSourceShape shape, Matrix4x4 transform, Vector3 size, Mesh mesh, int area)
{
Shape = shape;
Transform = transform;
Size = size;
Mesh = mesh;
Area = area;
}
///
/// Unity NavMesh source shape represented by this descriptor.
///
public NavMeshBuildSourceShape Shape { get; }
///
/// World transform used when the descriptor is converted into a runtime build source.
///
public Matrix4x4 Transform { get; }
///
/// Source size for primitive shapes such as box-based ground coverage.
///
public Vector3 Size { get; }
///
/// Source mesh for mesh-based obstacles or walkable surfaces when applicable.
///
public Mesh Mesh { get; }
///
/// Nav area assigned to the resulting build source.
///
public int Area { get; }
///
/// Creates a compact descriptor for box-based chunk geometry such as ground slabs.
///
public static ChunkNavBuildSourceDescriptor CreateBox(Matrix4x4 transform, Vector3 size, int area = 0)
{
return new ChunkNavBuildSourceDescriptor(NavMeshBuildSourceShape.Box, transform, size, null, area);
}
///
/// Creates a compact descriptor for mesh-based chunk geometry such as carved terrain or obstacles.
///
public static ChunkNavBuildSourceDescriptor CreateMesh(Matrix4x4 transform, Mesh mesh, int area = 0)
{
return new ChunkNavBuildSourceDescriptor(NavMeshBuildSourceShape.Mesh, transform, Vector3.zero, mesh, area);
}
}
///
/// Represents one gameplay-driven point that should influence nav coverage planning and clustering.
///
public readonly struct WorldInterestPoint
{
public WorldInterestPoint(Vector3 position, float priority, WorldInterestKind kind)
{
Position = position;
Priority = priority;
Kind = kind;
}
///
/// World position the planner should consider when shaping coverage.
///
public Vector3 Position { get; }
///
/// Relative weight used to prioritize coverage near more important interest points.
///
public float Priority { get; }
///
/// Category of interest so diagnostics can distinguish players, spawn anchors, hints and future AI sources.
///
public WorldInterestKind Kind { get; }
}
///
/// Lightweight read-model snapshot describing one currently managed nav coverage window.
///
public readonly struct NavCoverageWindowSnapshot
{
public NavCoverageWindowSnapshot(int id, Bounds bounds, NavCoverageState state, int interestCount)
{
Id = id;
Bounds = bounds;
State = state;
InterestCount = interestCount;
}
///
/// Stable runtime identifier of the coverage window.
///
public int Id { get; }
///
/// World-space bounds the window currently covers for pathing readiness.
///
public Bounds Bounds { get; }
///
/// Current lifecycle state of the window in the build scheduler.
///
public NavCoverageState State { get; }
///
/// Number of interest points currently collapsed into this window.
///
public int InterestCount { get; }
}
}