internal void SetValue(float value, ulong updateTick) { if (updateTick > pendingTick) { lastState = thisState; nextState.Reset(); pendingTick = updateTick; pendingCommit = true; } nextState.RawValue = value; nextState.Set(value, stateThreshold); }
void PrepareForUpdate(ulong updateTick) { if (updateTick < pendingTick) { throw new System.Exception("Cannot be updated with an earlier tick."); } if (pendingCommit && updateTick != pendingTick) { throw new System.Exception("Cannot be updated for a new tick until pending tick is committed."); } if (updateTick > pendingTick) { lastState = thisState; nextState.Reset(); pendingTick = updateTick; pendingCommit = true; } }
public void Commit() { pendingCommit = false; thisState = nextState; if (clearInputState) { lastState = nextState; UpdateTick = pendingTick; clearInputState = false; return; } var lastPressed = lastState.State; var thisPressed = thisState.State; if (lastPressed && !thisPressed) // if was released... { nextRepeatTime = 0.0f; } else if (thisPressed) // if is pressed... { if (lastPressed != thisPressed) // if has changed... { nextRepeatTime = Time.realtimeSinceStartup + FirstRepeatDelay; } else if (Time.realtimeSinceStartup >= nextRepeatTime) { nextRepeatTime = Time.realtimeSinceStartup + RepeatDelay; } } if (thisState != lastState) { UpdateTick = pendingTick; } }