public static float Tick(Stat stat, float currentTime) { float oldValue = stat.Value; stat.Value += (currentTime - stat.TimeStamp) * stat.ValueChangePerSecond; stat.TimeStamp = currentTime; if (stat.Value != oldValue) { stat.InvokeOnValueChangedEvent(); OnValueChanged?.Invoke(stat.Name, stat.Value); } if (stat.HasThreshhold) { if (stat.biggerThan && stat.Value <= stat.Threshhold) { stat.ThreshholdReached = false; stat.InvokeTreshHoldReached(false); OnThreshholdReached?.Invoke(stat.Name); } if (!stat.biggerThan && stat.Value >= stat.Threshhold) { stat.ThreshholdReached = true; stat.InvokeTreshHoldReached(true); OnThreshholdReached?.Invoke(stat.Name); } EvaluateBiggerThan(stat); } return(stat.Value); }
internal void InvokeTreshHoldReached(bool positive) { OnThreshholdReached?.Invoke(positive); }