using System.Collections; using System.Collections.Generic; using UnityEngine; [System.Serializable] public struct IndexValuePair<T> { [SerializeField] public int Key; [SerializeField] public T Value; public IndexValuePair(int key, T value) { Key = key; Value = value; } } /// <summary> /// Alias for ValueTouple class, pure touple (V, T) and also KeyValuePair /// </summary> /// <typeparam name="V"></typeparam> /// <typeparam name="T"></typeparam> [System.Serializable] public struct IndexValuePair<V, T> { [SerializeField] public V Key; [SerializeField] public T Value; public IndexValuePair(V key, T value) { Key = key; Value = value; } } [System.Serializable] //[CreateAssetMenu(fileName = "New Chest", menuName = "Inventory/Chest")] public class Chest { public int id; public int Id { get { return id; } set { id = value; } } public string name; public string Name { get { return name; } set { name = value; } } public string description; public string Description { get { return description; } set { description = value; } } public GameObject chestModel; public GameObject ChestModel { get { return chestModel; } set { chestModel = value; } } public ChestTypeEnum ChestType; [SerializeField] public List<IndexValuePair<EquippableItem>> Content = new List<IndexValuePair<EquippableItem>>(); public Chest() { } public Chest(Chest _chest) { this.Name = _chest.Name; this.Description = _chest.Description; this.ChestModel = _chest.ChestModel; this.ChestType = _chest.ChestType; this.Content = _chest.Content; } public Chest(string _name, string _description, GameObject _chestModel, ChestTypeEnum _type) { this.Name = _name; this.Description = _description; this.ChestModel = _chestModel; this.ChestType = _type; } public Chest(string _name, string _description, GameObject _chestModel, ChestTypeEnum _type, List<IndexValuePair<int, EquippableItem>> _content) { this.Name = _name; this.Description = _description; this.ChestModel = _chestModel; this.ChestType = _type; SetContent(_content); } public void SetContent(List<IndexValuePair<int, EquippableItem>> _content) { Content.Clear(); foreach (IndexValuePair<int, EquippableItem> element in _content) { Content.Add(new IndexValuePair<EquippableItem>(element.Key, element.Value)); } } public List<IndexValuePair<int, EquippableItem>> GetContent() { List<IndexValuePair<int, EquippableItem>> castedContent = new List<IndexValuePair<int, EquippableItem>>(); foreach (IndexValuePair<EquippableItem> element in Content) { castedContent.Add(new IndexValuePair<int, EquippableItem>(element.Key, element.Value)); } return castedContent; } }