using System.Collections; using System.Collections.Generic; using UnityEngine; using Sirenix.OdinInspector; using KairoEngine.Core; namespace KairoEngine.Statistics { public enum StatisticType { time, integer, text } [System.Serializable, HideMonoScript] public class StatisticData { [HorizontalGroup(180), HideLabel] public string title; [ShowIf("@category == StatisticType.time"), HorizontalGroup(), HideLabel, ShowInInspector] private float time; [ShowIf("@category == StatisticType.integer"), HorizontalGroup(), HideLabel, ShowInInspector] private int integer; [ShowIf("@category == StatisticType.text"), HorizontalGroup(), HideLabel, ShowInInspector] private string text; [HorizontalGroup(80), HideLabel] public StatisticType category; [HorizontalGroup(), HideLabel, Tooltip("Persistent Data?")] public bool persistent = false; public void AddTime(float t) { time += t; TriggerEvent(time); } public void AddInteger(int n) { integer += n; TriggerEvent(integer); } public float GetTime() => time; public int GetInteger() => integer; public string GetText() => text; public void SetTime(float t) { time = t; TriggerEvent(time); } public void SetInteger(int n) { integer = n; TriggerEvent(integer); } public void SetText(string t) { text = t; TriggerEvent(text); } public void Reset() { time = 0f; integer = 0; text = ""; } private void TriggerEvent(float time) => GenericEvents.Trigger("StatisticDataChanged", title, time); private void TriggerEvent(int integer) => GenericEvents.Trigger("StatisticDataChanged", title, integer); private void TriggerEvent(string text) => GenericEvents.Trigger("StatisticDataChanged", title, text); } }