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(); }
// 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); }
// Behaviour public override (IOBB_State state, StateAction stateAction) GetCurrent(IOBB_State currentState) { if (data.done()) { return(default);
public abstract (IOBB_State state, StateAction stateAction) GetCurrent(IOBB_State currentState);
// 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);