using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.EventSystems; namespace Invector.vItemManager { public class vEquipSlot : vItemSlot { [vEditorToolbar("Default")] [vHelpBox("Select what ItemType this EquipSlot will equip", vHelpBoxAttribute.MessageType.Warning)] public List itemType; public bool clickToOpen = true; public bool autoDeselect = true; public UnityEvent onCancel,onSetLockToEquip,onUnlockToEquip; public void SetLockToEquip(bool value) { if (value) onSetLockToEquip.Invoke(); else onUnlockToEquip.Invoke(); } /// /// Add item to slot /// /// target item public override void AddItem(vItem item) { if (item) item.isInEquipArea = true; base.AddItem(item); } /// /// Enable or disable checkIcon /// /// Enable or disable value public override void CheckItem(bool value) { if (checkIcon && checkIcon.gameObject.activeSelf) { checkIcon.gameObject.SetActive(false); } } /// /// Remove current item of the slot /// public override void RemoveItem() { if (item != null) item.isInEquipArea = false; base.RemoveItem(); } /// /// Event called when EquipSlot actions is canceled /// public virtual void OnCancel() { onCancel.Invoke(); } #region UnityEngine.EventSystems Implementation public override void OnDeselect(BaseEventData eventData) { if (autoDeselect) base.OnDeselect(eventData); } public override void OnPointerExit(PointerEventData eventData) { if (autoDeselect) base.OnPointerExit(eventData); } public override void OnPointerClick(PointerEventData eventData) { if (clickToOpen) base.OnPointerClick(eventData); } #endregion } }