add voxel world runtime navmesh sidecar
Introduce a DI-wired NavMesh sidecar for voxel chunks so world streaming stays actor-driven and world state remains the canonical source for navigation rebuilds.
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
namespace InfiniteWorld.VoxelWorld.Contracts
|
||||
{
|
||||
public interface IChunkNavSourceReader
|
||||
{
|
||||
float ChunkWorldSize { get; }
|
||||
void GetLoadedChunkCoords(List<Vector2Int> results);
|
||||
bool TryGetChunkNavSourceSnapshot(Vector2Int coord, out ChunkNavSourceSnapshot snapshot);
|
||||
}
|
||||
|
||||
public interface IWorldInterestReader
|
||||
{
|
||||
int InterestVersion { get; }
|
||||
void GetInterestPoints(List<WorldInterestPoint> results);
|
||||
}
|
||||
|
||||
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 enum WorldInterestKind
|
||||
{
|
||||
PlayerActor = 0,
|
||||
ActiveNpc = 1,
|
||||
Other = 2
|
||||
}
|
||||
|
||||
public readonly struct ChunkNavGeometryReadyMessage
|
||||
{
|
||||
public ChunkNavGeometryReadyMessage(Vector2Int coord, int version)
|
||||
{
|
||||
Coord = coord;
|
||||
Version = version;
|
||||
}
|
||||
|
||||
public Vector2Int Coord { get; }
|
||||
public int Version { get; }
|
||||
}
|
||||
|
||||
public readonly struct ChunkNavGeometryRemovedMessage
|
||||
{
|
||||
public ChunkNavGeometryRemovedMessage(Vector2Int coord, int version)
|
||||
{
|
||||
Coord = coord;
|
||||
Version = version;
|
||||
}
|
||||
|
||||
public Vector2Int Coord { get; }
|
||||
public int Version { get; }
|
||||
}
|
||||
|
||||
public readonly struct WorldInterestChangedMessage
|
||||
{
|
||||
public WorldInterestChangedMessage(int version)
|
||||
{
|
||||
Version = version;
|
||||
}
|
||||
|
||||
public int Version { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55dd8e2a1b2d458aa96895a54d53e6ca
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "VoxelWorld.Contracts",
|
||||
"rootNamespace": "InfiniteWorld.VoxelWorld.Contracts",
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 96b902ea5b554a1b8a9e0c29e03118f2
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user