using Platformer.Core; using Platformer.Mechanics; using UnityEngine; namespace Platformer.Gameplay { /// /// Fired when the health component on an enemy has a hitpoint value of 0. /// BT104 (PD 명시 2026-05-08): Enemy 사망 시 patrol·시각 영역 비활성 + 1초 후 GameObject Destroy /// public class EnemyDeath : Simulation.Event { public EnemyController enemy; public override void Execute() { if (enemy == null) return; // 충돌·이동·patrol 영역 비활성 if (enemy._collider != null) enemy._collider.enabled = false; if (enemy.control != null) enemy.control.enabled = false; enemy.enabled = false; // EnemyController patrol 영역 정지 // BT105 — 제자리 사망 (PD 명시 2026-05-08): Rigidbody2D simulated = false → gravity X·물리 미참여 var body = enemy.GetComponent(); if (body != null) body.simulated = false; // death 애니메이션 트리거 (Enemy.controller 영역의 'death' parameter) var animator = enemy.GetComponent(); if (animator != null) animator.SetTrigger("death"); // 사운드 if (enemy._audio != null && enemy.ouch != null) enemy._audio.PlayOneShot(enemy.ouch); // 1초 후 GameObject 영역 Destroy (사망 애니메이션 시간) Object.Destroy(enemy.gameObject, 1f); } } }