using UnityEngine;

namespace KitsuneCafe.Entities
{
    public class DamageSource : MonoBehaviour, IDamaging
    {
        [SerializeField]
        private int damage;

        public void ApplyDamage(Collider target)
        {
            ApplyDamage(damage, target);
        }

        public void ApplyDamage(GameObject target)
        {
            ApplyDamage(damage, target);
        }

        public void ApplyDamage(IDamageable target)
        {
            ApplyDamage(damage, target);
        }

        public void ApplyDamage(int amount, IDamageable target)
        {
            target.ReceiveDamage(this, amount);
        }

        public void ApplyDamage(int amount, Collider target)
        {
            ApplyDamage(amount, target.gameObject);
        }

        public void ApplyDamage(int amount, GameObject target)
        {
            if (target.TryGetComponent(out IDamageable damageable))
            {
                ApplyDamage(amount, damageable);
            }
        }
    }
}
