Beispiel #1
0
    // FixedUpdate is framerate independant
    void FixedUpdate()
    {
        if (!active || restingState == null)
        {
            return;
        }

        // 1. listen for substate updates
        for (int i = pushdownStates.Count - 1; i >= 0; i--)
        {
            // Check for expiration BEFORE listening. A trigger may remove the state, rendering expiration pointless.
            if (Time.time >= pushdownExpirationTimes[i])
            {
                // Debug.Log(pushdownStates[i] + " has expired.");
                RemoveSubstate(pushdownStates[i]);
            }
            else
            {
                pushdownStates[i].Listen(this);
            }
        }

        // 2. Check to see if a timed transition should occur
        if (Time.time >= transitionTime)
        {
            if (finiteState.TransitionState)   // If the state has it's own resting state
            {
                StateTransition(finiteState.TransitionState);
            }
            else
            {
                StateTransition(restingState); // Otherwise, use default resting state.
            }
        }

        // 3. listen for updates.
        finiteState.Listen(this);

        // 4. If Stateframe is in an IdleState, listen to Component States
        if (IsIdle())
        {
            for (int i = componentStates.Count - 1; i >= 0; i--)
            {
                componentStates[i].Listen(this);
            }
        }
    }