private void RunState(IOBB_State state, StateAction stateAction)
    {
        if (state == null)
        {
            state       = defaultState;
            stateAction = defaultStateAction;
        }

        // Change State
        if (currentStateAction != stateAction)
        {
            currentState?.OnExit();
            currentStateAction.end?.Invoke();

            currentState       = state;
            currentStateAction = stateAction;

            currentStateAction.start?.Invoke();
            currentState.OnEnter();
            canRunLateEnter = true;
        }

        // Run State Action Update
        currentStateAction.update?.Invoke();
    }
Example #2
0
        // Ctor
        public Single(IOBB_State state, StateAction stateAction, Func <bool> done)
        {
            if (state == null)
            {
                Debug.LogError($"{state.GetType().Name} is Null!");
                return;
            }

            data = (state, stateAction, done);
        }
Example #3
0
 // Behaviour
 public override (IOBB_State state, StateAction stateAction) GetCurrent(IOBB_State currentState)
 {
     if (data.done())
     {
         return(default);
Example #4
0
 public abstract (IOBB_State state, StateAction stateAction) GetCurrent(IOBB_State currentState);
Example #5
0
        // Get Current
        public (OBB_Behaviour behaviour, IOBB_State state, StateAction stateAction) GetCurrent(IOBB_State currentState)
        {
            for (int i = 0; i < behaviours.Count; i++)
            {
                var current = behaviours[i].GetCurrent(currentState);
                if (current.state != null)
                {
                    return(behaviours[i], current.state, current.stateAction);
                }
            }

            return(default);