/// <summary> /// Processes the value changes and emits the appropriate events. /// </summary> public virtual void Process() { if (!isActiveAndEnabled) { return; } if (!Value.ApproxEquals(previousValue)) { previousValue = Value; EmitValueChanged(); EmitNormalizedValueChanged(); } if (!StepValue.ApproxEquals(previousStepValue)) { previousStepValue = StepValue; EmitStepValueChanged(); } float targetValue = GetTargetValue(); bool targetValueReached = NormalizedValue.ApproxEquals(targetValue, targetValueReachedThreshold); bool shouldEmitEvent = !previousTargetValueReached && targetValueReached; previousTargetValueReached = targetValueReached; if (CanMoveToTargetValue() && shouldEmitEvent) { EmitTargetValueReached(); } }
/// <summary> /// Checks if the <see cref="StepValue"/> has changed. /// </summary> protected virtual void CheckStepValueChange() { if (!StepValue.ApproxEquals(previousStepValue)) { previousStepValue = StepValue; EmitStepValueChanged(); } }
public virtual void Process() { if (wasDisabled || !Value.ApproxEquals(previousValue)) { if (!isMoving && previousValue < float.MaxValue) { EmitStartedMoving(); isMoving = true; } previousValue = Value; EmitValueChanged(); EmitNormalizedValueChanged(); } else { if (isMoving) { EmitStoppedMoving(); isMoving = false; } } if (!StepValue.ApproxEquals(previousStepValue)) { previousStepValue = StepValue; EmitStepValueChanged(); } float targetValue = GetTargetValue(); bool targetValueReached = NormalizedValue.ApproxEquals(targetValue, TargetValueReachedThreshold); bool shouldEmitEvent = !previousTargetValueReached && targetValueReached; previousTargetValueReached = targetValueReached; if (CanMoveToTargetValue() && shouldEmitEvent) { EmitTargetValueReached(); } wasDisabled = false; }