Files
2024-11-20 15:21:28 +01:00

94 lines
2.5 KiB
C#

using Invector;
using Invector.vItemManager;
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
namespace Beyond
{
public class bEquipSlot : bItemSlot
{
[vEditorToolbar("Default")]
[vHelpBox("Select what ItemType this EquipSlot will equip", vHelpBoxAttribute.MessageType.Warning)]
public List<bItemType> 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();
}
/// <summary>
/// Add item to slot
/// </summary>
/// <param name="item">target item</param>
public override void AddItem(bItem item)
{
// Debug.Log("add item to equip slot ");
if (item)
{
item.checkColor = checkColor;
item.isInEquipArea = true;
}
base.AddItem(item);
}
/// <summary>
/// Enable or disable checkIcon
/// </summary>
/// <param name="value">Enable or disable value</param>
public override void CheckItem(bool value)
{
if (checkIcon && checkIcon.gameObject.activeSelf)
{
checkIcon.gameObject.SetActive(false);
}
}
/// <summary>
/// Remove current item of the slot
/// </summary>
public override void RemoveItem()
{
if (item != null) item.isInEquipArea = false;
base.RemoveItem();
}
/// <summary>
/// Event called when EquipSlot actions is canceled
/// </summary>
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 UnityEngine.EventSystems Implementation
}
}