Files
Project-M/Assets/_Project/Scripts/Simulation/Player/PlayerDeathStateSystem.cs
T
kronic e362aaeb43 Import art/VFX asset packs + game-feel systems; normalize texture extensions to lowercase for LFS
Add BefourStudios SciFi environment packs, Gabriel Aguiar VFX, and the
ShaderCrew Toon Shader embedded packages, plus combat/enemy/wave/death
gameplay systems and supporting vault docs/screenshots.

Rename 11 vendor textures from uppercase .PNG/.HDR to lowercase so the
case-sensitive Git LFS filters (*.png/*.hdr) match on case-sensitive
filesystems (Linux CI, case-sensitive macOS), not just locally where
core.ignorecase=true masks the gap. Each .meta moved with its asset so
GUID references are preserved. All ~1000 binaries tracked via LFS.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 22:50:43 -07:00

43 lines
2.1 KiB
C#

using Unity.Burst;
using Unity.Entities;
using Unity.Mathematics;
using Unity.NetCode;
namespace ProjectM.Simulation
{
/// <summary>
/// Derives the LOCAL enableable <see cref="Dead"/> gate from the replicated <see cref="Health"/> every predicted
/// tick (Dead == Health.Current &lt;= 0). Runs in BOTH worlds inside
/// <see cref="PredictedSimulationSystemGroup"/>, BEFORE movement/aim/fire, so a dead player is excluded from
/// those systems (which query <c>.WithDisabled&lt;Dead&gt;()</c>) on the server AND the owner-predicting client.
/// Because it is a pure function of the already-replicated, reconciled Health (the same derive-don't-replicate
/// pattern as <see cref="StatRecomputeSystem"/>), the gate is identical across server, owner-client, and rollback
/// — no replicated enabled bit required. Also zeroes <see cref="CharacterControl.MoveVelocity"/> while dead so
/// the kinematic character holds still (the movement system is skipped and would otherwise coast on stale
/// velocity). The authoritative recovery (Health refill + reposition) is owned server-side by
/// <c>PlayerRespawnSystem</c>. Visits dead players too via <c>.WithPresent&lt;Dead&gt;()</c> (required to write
/// the enabled bit on an entity whose Dead is currently disabled).
/// </summary>
[UpdateInGroup(typeof(PredictedSimulationSystemGroup))]
[UpdateBefore(typeof(PlayerControlSystem))]
[UpdateBefore(typeof(PlayerAimSystem))]
[BurstCompile]
public partial struct PlayerDeathStateSystem : ISystem
{
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
foreach (var (health, control, deadEnabled) in
SystemAPI.Query<RefRO<Health>, RefRW<CharacterControl>, EnabledRefRW<Dead>>()
.WithAll<PlayerTag, Simulate>()
.WithPresent<Dead>())
{
bool isDead = health.ValueRO.Current <= 0f;
deadEnabled.ValueRW = isDead;
if (isDead)
control.ValueRW.MoveVelocity = float3.zero;
}
}
}
}