Files
Project-M/Assets/_Project/Scripts/Simulation/Combat/KnockbackState.cs
T
2026-06-04 11:35:57 -07:00

27 lines
1.3 KiB
C#

using Unity.Entities;
using Unity.Mathematics;
namespace ProjectM.Simulation
{
/// <summary>
/// SERVER-ONLY transient knockback on a Husk. While <see cref="UntilTick"/> has not elapsed, EnemyAISystem
/// moves the Husk along <see cref="Dir"/> at <see cref="Speed"/> (REPLACING its seek) and suppresses its strike.
/// Stamped by ProjectileDamageSystem on a hit (Dir = the projectile's heading). NOT a [GhostField] — the Husk's
/// displaced position already replicates via the stock LocalTransform default variant, so knockback adds NO
/// replicated surface (no ghost re-bake). EnemyAISystem must remain the SOLE writer of the Husk's Position, so
/// knockback is applied INSIDE it (never a competing system). Force/duration live in <see cref="Tuning"/>
/// (KnockbackSpeed = 0 disables knockback globally).
/// </summary>
public struct KnockbackState : IComponentData
{
/// <summary>Planar (XZ) knockback heading — the projectile's direction at impact.</summary>
public float2 Dir;
/// <summary>Knockback speed (world units/sec) applied for the window; 0 = not knocked.</summary>
public float Speed;
/// <summary>Server tick until which the knockback is active (0 = none; scheduled via TickUtil.NonZero).</summary>
public uint UntilTick;
}
}