using System.Collections; using System.Collections.Generic; using UnityEngine; using KairoEngine.Stats; using Sirenix.OdinInspector; namespace KairoEngine.Stockpiles { [System.Serializable] public class StockpileGroup { [FoldoutGroup("@groupName"), PropertySpace(4,4)] public string owner; public string groupName { get { return $"{owner} Resources"; }} [FoldoutGroup("@groupName"), HideIf("@stats.statGroup != null")] public List initialStockpiles = new List(); [FoldoutGroup("@groupName"), InlineProperty, HideLabel, HideIf("@stats.statGroup == null"), PropertySpace(4,2)] public StatsController stats = new StatsController(); public void Initialize(List resourceTypes) { StatGroup statGroup = (StatGroup)ScriptableObject.CreateInstance("StatGroup"); StatTemplate statTemplateSource = (StatTemplate)ScriptableObject.CreateInstance("StatTemplate"); for (int i = 0; i < resourceTypes.Count; i++) { StatTemplate statTemplate = ScriptableObject.Instantiate(statTemplateSource); statTemplate.minValue = 0; statTemplate.maxValue = 0; statTemplate.initialValue = 0; statTemplate.title = resourceTypes[i].title; statTemplate.minValue = resourceTypes[i].minValue; statTemplate.maxValue = resourceTypes[i].maxValue; statTemplate.initialValue = resourceTypes[i].initialValue; for (int v = 0; v < initialStockpiles.Count; v++) { if(initialStockpiles[v].stockpileType.title == resourceTypes[i].title) { statTemplate.initialValue += initialStockpiles[v].ammount; statTemplate.maxValue += initialStockpiles[v].capacity; } } statGroup.statTemplates.Add(statTemplate); } stats.statGroup = statGroup; stats.Initialize(); } } }