ItemContainer.cs 943 B

123456789101112131415161718192021222324252627282930
  1. using System.Collections.Generic;
  2. using Assets.HeroEditor4D.InventorySystem.Scripts.Data;
  3. using UnityEngine;
  4. namespace Assets.HeroEditor4D.InventorySystem.Scripts.Elements
  5. {
  6. /// <summary>
  7. /// Abstract item container. It can be inventory bag, player equipment or trader goods.
  8. /// </summary>
  9. public abstract class ItemContainer : MonoBehaviour
  10. {
  11. /// <summary>
  12. /// List of items.
  13. /// </summary>
  14. public List<Item> Items { get; protected set; } = new List<Item>();
  15. [Header("Settings")]
  16. [Tooltip("Stack identical inventory items to a single UI element.")]
  17. public bool Stacked = true;
  18. public bool AutoSelect = true;
  19. public abstract void Refresh(Item selected);
  20. public void Initialize(ref List<Item> items, Item selected = null)
  21. {
  22. Items = items;
  23. Refresh(selected);
  24. }
  25. }
  26. }