using System;
using Sirenix.OdinInspector;
using UnityEngine;
using VOID.Generic.Dict;
using VOID.Generic.Objects.Unit;
using VOID.Generic.Objects.Weapon;

namespace VOID.Generic.Requirement
{
    [TypeRegistryItem("Equipped Weapon Type")]
    [Serializable]
    public class RequirementWeaponType : IUnitRequirement
    {
        [SerializeField]
        [Required]
        private WeaponType _weaponType;

        public bool Check(UnitObject unit)
        {
            if (_weaponType == WeaponType.None)
                return !(unit.unitEquipment.GetEquipped(EquipmentSlotType.MainHand)
                    || unit.unitEquipment.GetEquipped(EquipmentSlotType.OffHand));

            return ((WeaponObject)unit.unitEquipment.GetEquipped(EquipmentSlotType.MainHand))?.weaponData.weaponType == _weaponType
                || ((WeaponObject)unit.unitEquipment.GetEquipped(EquipmentSlotType.OffHand))?.weaponData.weaponType == _weaponType;
        }
    }
}