// using UnityEngine; // // public interface IDamageable // { // void TakeDamage(int amount, Vector3 hitPoint, Vector3 hitNormal, GameObject attacker); // } // // // // public abstract class Weapon : MonoBehaviour // { // [Header("Base Stats")] // [SerializeField] protected int baseDamage = 5; // [SerializeField] protected LayerMask hitMask; // // [SerializeField] protected Weapon_Damage weaponDamage; // 동일 오브젝트나 자식에 부착 // [SerializeField] protected bool autoFindDamageComponent = true; // // protected PlayerController owner; // protected Status_Player ownerStatus; // 공격력 배율 등 // protected bool initialized; // // public virtual void Initialize(PlayerController owner, Status_Player status) // { // this.owner = owner; // ownerStatus = status; // // if (autoFindDamageComponent && weaponDamage == null) // weaponDamage = GetComponentInChildren(true); // // if (weaponDamage != null) // weaponDamage.Init(this, hitMask); // // initialized = true; // } // // // 애니메이션 이벤트에서 호출 // public void AttackEnableHit() // { // if (weaponDamage != null) weaponDamage.EnableHit(); // OnAttackWindowOpened(); // } // // // 애니메이션 이벤트에서 호출 // public void AttackDisableHit() // { // if (weaponDamage != null) weaponDamage.DisableHit(); // OnAttackWindowClosed(); // } // // // WeaponDamage -> OnTriggerEnter -> 여기로 집결 // public void HandleHit(IDamageable target, Vector3 hitPoint, Vector3 hitNormal, GameObject targetGO) // { // int dmg = ComputeFinalDamage(); // OnPreApplyDamage(target, ref dmg, hitPoint, hitNormal); // target.TakeDamage(dmg, hitPoint, hitNormal, owner != null ? owner.gameObject : gameObject); // OnPostApplyDamage(target, dmg, hitPoint, hitNormal); // } // // protected virtual int ComputeFinalDamage() // { // float statMul = 1f; // if (ownerStatus != null) // statMul = ownerStatus.Atk; // 외부 스탯 곱 // int dmg = Mathf.RoundToInt(baseDamage * statMul); // dmg = Mathf.Max(1, dmg); // return ModifyDamage(dmg); // } // // // 자식에서 수치 커스터마이즈 // protected virtual int ModifyDamage(int current) => current; // // // 공격 판정 구간 열림/닫힘 훅 // protected virtual void OnAttackWindowOpened() { } // protected virtual void OnAttackWindowClosed() { } // // // 실제 데미지 적용 직전/직후 훅 // protected virtual void OnPreApplyDamage(IDamageable target, ref int damage, Vector3 point, Vector3 normal) { } // protected virtual void OnPostApplyDamage(IDamageable target, int damage, Vector3 point, Vector3 normal) { } // }