예제 #1
0
    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);
    }
예제 #2
0
    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;
        }
    }
예제 #3
0
    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;
        }
    }