using System.Collections.Generic; using UnityEngine; // BaseSlot.cs public class Slot : ScriptableObject { public enum SlotType { Inventory, Toolbar, Equipment, Crafting, Chest, Shop, Quest } public GameItem item; public int quantity; public int slotId = -1; public bool isLocked; public SlotType slotType; public List allowedItemTypes = new(); public Slot() { item = null; quantity = 0; isLocked = false; } public virtual void Initialize(GameItem gameItem, int qty) { item = gameItem; quantity = qty; } public virtual void AssignGameItem(GameItem gameItem, int qty = 1) { item = gameItem; quantity = qty; } public virtual void AddQuantity(int amount) { quantity += amount; } public virtual void RemoveQuantity(int amount) { quantity -= amount; } public virtual void SetQuantity(int amount) { quantity = amount; } public virtual bool IsEmpty() { return item == null; } public virtual Sprite GetIcon() { return item != null ? item.icon : null; } public virtual string GetItemName() { return item != null ? item.name : string.Empty; } public virtual float GetItemValue() { return item != null ? item.itemValue : 0f; } public bool IsSlotType() where T : Slot { return this is T; } public void SetSlotType(SlotType type) { slotType = type; } public void SetSlotId(int id) { slotId = id; } public void SetLocked(bool locked) { isLocked = locked; } public void SetAllowedItemTypes(List types) { allowedItemTypes = types; } public void AddAllowedItemType(GameItem.ItemType type) { allowedItemTypes.Add(type); } public void RemoveAllowedItemType(GameItem.ItemType type) { allowedItemTypes.Remove(type); } public bool IsAllowedItemType(GameItem.ItemType type) { return allowedItemTypes.Contains(type); } public void ClearAllowedItemTypes() { allowedItemTypes.Clear(); } public List GetAllowedItemTypes() { return allowedItemTypes; } public void ClearSlot() { item = null; quantity = 0; } public bool IsAllowedItemTypes(GameItem.ItemType type) { var isAllowed = false; Debug.Log("Checking allowed item types"); Debug.Log("Allowed item types: " + allowedItemTypes + " / " + type); // pretty print list foreach (var allowedItemType in allowedItemTypes) { Debug.Log("-- allowed" + allowedItemType); if (allowedItemType == type) { Debug.Log("Item type is allowed in slot: " + type); isAllowed = true; break; } } return isAllowed; } }