using UnityEngine; namespace SLSFramework.General { public class CompoundVariable { public int trueCount; private T positiveValue; private T zeroAndNegativeValue; public T value => trueCount > 0 ? positiveValue : zeroAndNegativeValue; public CompoundVariable(bool reverse = false) { if (typeof(T) == typeof(bool)) { positiveValue = (T)(object)true; zeroAndNegativeValue = (T)(object)false; trueCount = reverse ? 1 : 0; } else { throw new System.Exception("CompoundVariable default constructor only supports bool type."); } } public CompoundVariable(T positiveValue, T zeroAndNegativeValue) { this.positiveValue = positiveValue; this.zeroAndNegativeValue = zeroAndNegativeValue; trueCount = 0; } public void Modify(bool marker) { if (marker) { trueCount++; } else { trueCount--; } } public void Reset() { trueCount = 0; } } }