using UnityEngine; using Platformer.Mechanics; namespace EerieVillage.Skills.Effectors { /// /// 적 상태 컴포넌트 통합 파일. /// DoT·Stun·Slow 세 MonoBehaviour를 단일 파일에 정의 (C14 토큰·파일 최소화). /// BT12-Dev Phase 2-B §4-7. /// // ------------------------------------------------------------------------- // EnemyDoTState — 화염 지속 대미지 // ------------------------------------------------------------------------- /// /// 적에게 주기적 DoT(Damage over Time)을 가하는 컴포넌트. /// StatusApplier.ApplyDoT 에서 AddComponent 또는 기존 컴포넌트 재사용. /// 동일 적에 복수 AddDoT 호출 시 마지막 호출로 덮어씌운다 (스택 비허용 — Phase 2 범위). /// public class EnemyDoTState : MonoBehaviour { private int _damagePerTick; private float _duration; private float _interval; private float _elapsed; private float _tickElapsed; public void AddDoT(int dmg, float duration, float interval) { _damagePerTick = dmg; _duration = duration; _interval = interval; _elapsed = 0f; _tickElapsed = 0f; } private void Update() { if (_duration <= 0f) return; _elapsed += Time.deltaTime; _tickElapsed += Time.deltaTime; if (_tickElapsed >= _interval) { _tickElapsed = 0f; var hp = GetComponent(); if (hp != null && hp.IsAlive) hp.Decrement(_damagePerTick); } if (_elapsed >= _duration) Destroy(this); } } // ------------------------------------------------------------------------- // EnemyStunState — 기절 (EnemyController.enabled = false) // ------------------------------------------------------------------------- /// /// 적을 기절시키는 컴포넌트. /// EnemyController.enabled = false 로 patrol·Update 를 일시 정지한다. /// 지속 시간 만료 시 EnemyController.enabled = true 복원. /// public class EnemyStunState : MonoBehaviour { private float _duration; private float _elapsed; private EnemyController _enemy; private void Awake() { _enemy = GetComponent(); } public void ApplyStun(float duration) { _duration = duration; _elapsed = 0f; if (_enemy != null) _enemy.enabled = false; } private void Update() { if (_duration <= 0f) return; _elapsed += Time.deltaTime; if (_elapsed >= _duration) { if (_enemy != null) _enemy.enabled = true; Destroy(this); } } } // ------------------------------------------------------------------------- // EnemySlowState — 감속 (AnimationController.maxSpeed 축소) // ------------------------------------------------------------------------- /// /// 적을 감속시키는 컴포넌트. /// AnimationController.maxSpeed 를 multiplier 배율로 축소하고, 지속 시간 만료 시 원복. /// EnemyController 는 AnimationController 를 RequireComponent 하므로 항상 존재. /// public class EnemySlowState : MonoBehaviour { private float _duration; private float _multiplier; private float _elapsed; private float _origMaxSpeed; private AnimationController _anim; private void Awake() { _anim = GetComponent(); _origMaxSpeed = _anim != null ? _anim.maxSpeed : 0f; } public void ApplySlow(float duration, float multiplier) { _duration = duration; _multiplier = multiplier; _elapsed = 0f; if (_anim != null) _anim.maxSpeed = _origMaxSpeed * _multiplier; } private void Update() { if (_duration <= 0f) return; _elapsed += Time.deltaTime; if (_elapsed >= _duration) { if (_anim != null) _anim.maxSpeed = _origMaxSpeed; Destroy(this); } } } }