26 lines
1.0 KiB
C#
26 lines
1.0 KiB
C#
using Platformer.Core;
|
|
using Platformer.Mechanics;
|
|
using static Platformer.Core.Simulation;
|
|
|
|
namespace Platformer.Gameplay
|
|
{
|
|
/// <summary>
|
|
/// Fired when the player health reaches 0. This usually would result in a
|
|
/// PlayerDeath event.
|
|
/// BT12-Dev 2026-05-09 — sender 가드 추가. Enemy.Health hp=0 시 무차별 PlayerDeath 발화 차단.
|
|
/// 근본: Health.Decrement·Die 4곳에서 Schedule<HealthIsZero>(sender 미구분) → Execute에서 PlayerDeath 직결 → 적 처치 시 Player 즉사 버그.
|
|
/// </summary>
|
|
/// <typeparam name="HealthIsZero"></typeparam>
|
|
public class HealthIsZero : Simulation.Event<HealthIsZero>
|
|
{
|
|
public Health health;
|
|
|
|
public override void Execute()
|
|
{
|
|
if (health == null) return;
|
|
// PlayerController 보유 Health만 PlayerDeath 발화 (Enemy 등 다른 Health 영역 차단).
|
|
if (health.GetComponent<PlayerController>() == null) return;
|
|
Schedule<PlayerDeath>();
|
|
}
|
|
}
|
|
} |