using System;
using UnityEngine;

namespace Unicorn.Hitbox
{
    public class UnicornHitbox : MonoBehaviour
    {
        public UnicornHitboxDataSObj hitboxData;
        
        private SpriteRenderer _spriteRenderer;
        private bool _hitable = false;

        private void Start()
        {
            _spriteRenderer = GetComponent<SpriteRenderer>();
            _hitable = false;
        }

        private void OnTriggerEnter2D(Collider2D other)
        {
            if (!other.TryGetComponent(out LivingEntity target)) return;
            var info = new DamageInfo
            {
                Damage = hitboxData.damage,
                KnockbackForce = hitboxData.knockbackForce,
                HitPoint = transform.position
            };

            target.Damage(info);
        }
    }
}