using System.Collections; using System.Collections.Generic; using UnityEngine; using System; namespace BITKit { [System.Serializable] public class TempValue { public static implicit operator T(TempValue self) => self.Get(); public static implicit operator bool(TempValue self) => self.IsActive(); public IEnumerable optionals = new List(); public T value = default; public float lowValue = -90; public float highValue = 90; public bool locked; Action onValueChanged; IntervalUpdate active = new(1); public T Get() => value; public bool IsActive() { if (locked) { return true; } else { return active.AllowUpdateWithoutReset is false; } } public void Set(T t) { value = t; onValueChanged?.Invoke(value); active.Reset(); } public void SetOptionals(IEnumerable optionals) { this.optionals = optionals; } public void AddListener(Action action) { onValueChanged += action; } public void RemoveListener(Action action) { onValueChanged -= action; } } }