using UnityEngine;

namespace Nan.Scripts
{
    public class HitPointRegeneration : MonoBehaviour
    {
        [SerializeField]private int _recoveryValue;

        public int RecoveryValue
        {
            get { return _recoveryValue; }
            set { _recoveryValue = value > 0 ? value : -value; }
        }

        private void OnTriggerEnter2D(Collider2D other)
        {
            if (other.tag == "player")
            {
                other.GetComponent<PlayerStatus>().Health += RecoveryValue;
                Destroy(gameObject);
            }
        }
    }
}
