Files
Project-M/Assets/_Project/Scripts/Simulation/Combat/EnemyNavState.cs
T
2026-07-07 20:51:18 -07:00

29 lines
1.6 KiB
C#

using Unity.Entities;
using Unity.Mathematics;
namespace ProjectM.Simulation
{
/// <summary>
/// Server-only per-Husk navigation / anti-stuck state (NOT replicated — clients never simulate enemies, so this
/// carries no <c>[GhostField]</c> and does not change the ghost hash). Tracks the enemy's XZ position at the end
/// of last tick plus how long it has failed to make progress toward its target, so <c>EnemyAISystem</c> can
/// phase-nudge a genuinely stuck enemy (wedged on a cover rock or a rock-vs-boundary pocket) toward the nearest
/// player — the guaranteed backstop that keeps an expedition room from ever soft-locking on one unreachable Husk.
/// Baked onto every enemy by <c>EnemyAuthoring</c>. Complements the collide-and-slide fixes in
/// <see cref="EnemyAIMath.SlideVelocity"/> / <c>EnemyMoveUtil</c> (which make sticking rare in the first place).
/// </summary>
public struct EnemyNavState : IComponentData
{
/// <summary>Enemy XZ position at the end of last tick (progress baseline; Y unused).</summary>
public float3 LastPos;
/// <summary>Consecutive ticks the enemy wanted to move toward its target but made ~no progress.</summary>
public uint StuckTicks;
/// <summary>While a <c>NetworkTick</c> newer than the current tick is stored here the enemy is phase-nudging
/// toward its target (collide-and-slide bypassed) to escape geometry; <c>0</c> = not nudging. Routed through
/// <c>TickUtil.NonZero</c> so a computed tick never collides with the 0 "inactive" sentinel.</summary>
public uint NudgeUntilTick;
}
}