using System.Collections; using System.Collections.Generic; using UnityEngine; [System.Serializable] public struct IndexValuePair { [SerializeField] public int Key; [SerializeField] public T Value; public IndexValuePair(int 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; public List> Content = new List>(); 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> _content) { this.Name = _name; this.Description = _description; this.ChestModel = _chestModel; this.ChestType = _type; SetContent(_content); } public void SetContent(List> _content) { Content.Clear(); foreach (KeyValuePair element in _content) { Content.Add(new IndexValuePair(element.Key, element.Value)); } } public List> GetContent() { List> castedContent = new List>(); foreach (IndexValuePair element in Content) { castedContent.Add(new KeyValuePair(element.Key, element.Value)); } return castedContent; } }