using UnityEngine; using Platformer.Mechanics; namespace EerieVillage.Skills.Effectors { /// /// PD 지시 2026-05-13 — Inspector 영역 ActiveSkillData 값 변경 시 살아있는 시각화 박스도 즉시 반영. /// LateUpdate 매 frame data 정합 갱신: position·rotation·localScale. /// public class LiveHitboxSync : MonoBehaviour { public enum FollowMode { /// Anchor + (0, OffsetDistance) + OffsetXY · size=HitboxSize · rot=FxRotation (A05 MeleeArea) AnchorYOffset, /// Anchor (Enemy) + (0, OffsetDistance) + OffsetXY · size=HitboxSize · rot=FxRotation (A04 Lightning·primary 사망 시 마지막 위치 유지) EnemyAnchoredAtStrike, /// Anchor (Player) + facing × (OffsetDistance + length/2) + OffsetXY · size=(length, width) · rot=facing+FxRotation (A_Laser) PlayerFacingLaser, } public ActiveSkillData Data; public Transform Anchor; public FollowMode Mode; // PlayerFacingLaser 영역 영역 — Anchor (Player) 영역 PlayerController.Facing 영역 영역 public PlayerController PlayerCtrl; // EnemyAnchoredAtStrike — Anchor (primary enemy) 사망 시 마지막 위치 캐싱 Vector2 _lastAnchorPos; bool _hasLastPos; void LateUpdate() { if (Data == null) return; Vector2 anchorPos; if (Anchor != null) { anchorPos = Anchor.position; _lastAnchorPos = anchorPos; _hasLastPos = true; } else if (_hasLastPos) anchorPos = _lastAnchorPos; else return; Vector2 pos = anchorPos; float angle = 0f; Vector3 scale = transform.localScale; switch (Mode) { case FollowMode.AnchorYOffset: case FollowMode.EnemyAnchoredAtStrike: pos += Data.OffsetDistance + Data.OffsetXY; angle = Data.FxRotation; scale = new Vector3(Data.HitboxSize.x, Data.HitboxSize.y, 1f); break; case FollowMode.PlayerFacingLaser: Vector2 facing = (PlayerCtrl != null) ? PlayerCtrl.Facing : Vector2.right; facing = facing.normalized; float length = Mathf.Max(Data.HitboxSize.x, 1f); float width = Mathf.Max(Data.HitboxSize.y, 0.5f); pos += Data.OffsetDistance + Data.OffsetXY + facing * (length * 0.5f); angle = Mathf.Atan2(facing.y, facing.x) * Mathf.Rad2Deg + Data.FxRotation; scale = new Vector3(length, width, 1f); break; } transform.position = pos; transform.rotation = Quaternion.Euler(0f, 0f, angle); transform.localScale = scale; } } }