enemy spawner

This commit is contained in:
2025-10-26 14:17:31 +01:00
parent 20d3b46834
commit 40a62b5b5a
2102 changed files with 1255290 additions and 70 deletions

View File

@@ -0,0 +1,47 @@
using System;
using UnityEngine.AI;
namespace Game.Scripts.Runtime.Navigation
{
/// <summary>
/// Lightweight cache around NavMesh availability checks so gameplay code
/// can gracefully degrade when a bake is not present.
/// </summary>
public static class NavMeshRuntimeUtility
{
private static bool? _cachedHasNavMesh;
/// <summary>
/// Returns true if there is any baked NavMesh data loaded at runtime.
/// Result is cached until <see cref="InvalidateCache"/> is called.
/// </summary>
public static bool HasNavMeshData()
{
if (_cachedHasNavMesh.HasValue)
{
return _cachedHasNavMesh.Value;
}
try
{
var triangulation = NavMesh.CalculateTriangulation();
var hasData = triangulation.vertices != null && triangulation.vertices.Length > 0;
_cachedHasNavMesh = hasData;
return hasData;
}
catch (Exception)
{
_cachedHasNavMesh = false;
return false;
}
}
/// <summary>
/// Clears the cached NavMesh availability state. Call this after baking at runtime.
/// </summary>
public static void InvalidateCache()
{
_cachedHasNavMesh = null;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 19ab015c2ac2d472aa3d70eedc029e97