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.
78 lines
2.4 KiB
C#
78 lines
2.4 KiB
C#
using UnityEngine;
|
|
using UnityEngine.AI;
|
|
|
|
namespace InfiniteWorld.VoxelWorld.Contracts
|
|
{
|
|
public readonly struct ChunkNavSourceSnapshot
|
|
{
|
|
public ChunkNavSourceSnapshot(Vector2Int coord, int version, ChunkNavBuildSourceDescriptor[] sources)
|
|
{
|
|
Coord = coord;
|
|
Version = version;
|
|
Sources = sources;
|
|
}
|
|
|
|
public Vector2Int Coord { get; }
|
|
public int Version { get; }
|
|
public ChunkNavBuildSourceDescriptor[] Sources { get; }
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
public NavMeshBuildSourceShape Shape { get; }
|
|
public Matrix4x4 Transform { get; }
|
|
public Vector3 Size { get; }
|
|
public Mesh Mesh { get; }
|
|
public int Area { get; }
|
|
|
|
public static ChunkNavBuildSourceDescriptor CreateBox(Matrix4x4 transform, Vector3 size, int area = 0)
|
|
{
|
|
return new ChunkNavBuildSourceDescriptor(NavMeshBuildSourceShape.Box, transform, size, null, area);
|
|
}
|
|
|
|
public static ChunkNavBuildSourceDescriptor CreateMesh(Matrix4x4 transform, Mesh mesh, int area = 0)
|
|
{
|
|
return new ChunkNavBuildSourceDescriptor(NavMeshBuildSourceShape.Mesh, transform, Vector3.zero, mesh, area);
|
|
}
|
|
}
|
|
|
|
public readonly struct WorldInterestPoint
|
|
{
|
|
public WorldInterestPoint(Vector3 position, float priority, WorldInterestKind kind)
|
|
{
|
|
Position = position;
|
|
Priority = priority;
|
|
Kind = kind;
|
|
}
|
|
|
|
public Vector3 Position { get; }
|
|
public float Priority { get; }
|
|
public WorldInterestKind Kind { get; }
|
|
}
|
|
|
|
public readonly struct NavCoverageWindowSnapshot
|
|
{
|
|
public NavCoverageWindowSnapshot(int id, Bounds bounds, NavCoverageState state, int interestCount)
|
|
{
|
|
Id = id;
|
|
Bounds = bounds;
|
|
State = state;
|
|
InterestCount = interestCount;
|
|
}
|
|
|
|
public int Id { get; }
|
|
public Bounds Bounds { get; }
|
|
public NavCoverageState State { get; }
|
|
public int InterestCount { get; }
|
|
}
|
|
}
|