public void AddState(GKStateMachineStateBase <STATE_ID_T> state, bool asDefault) { _states.Add(state); if (asDefault) { _defaultState = state; _lastState = state; } }
void _RemoveCurrentState(STATE_ID_T stateId, bool isNormal) { GKStateMachineStateBase <STATE_ID_T> state = _GetStateById(stateId); if (state != null && _currentState.Contains(state)) { if (isNormal) { state.Exit(); } _lastState = state; _currentState.Remove(state); } }
void _AddCurrentState(STATE_ID_T stateId, string parm, object val) { GKStateMachineStateBase <STATE_ID_T> state = _GetStateById(stateId); if (null == state) { return; } state.Trigger(parm, val); if (!_currentState.Contains(state)) { _currentState.Add(state); state.Enter(); } }
public void Update() { if (_states.Count == 0) { return; } if (_currentState.Count == 0) { if (_defaultState == null) { return; } _currentAddingState.Add(new NewStateStruct(_defaultState.ID, "", null)); _defaultState = null; } if (0 != _currentAddingState.Count) { foreach (var state in _currentAddingState) { _AddCurrentState(state.state, state.parm, state.value); } _currentAddingState.Clear(); } if (0 != _currentRemovingState.Count) { foreach (var state in _currentRemovingState) { _RemoveCurrentState(state.Key, state.Value); } _currentRemovingState.Clear(); } if (_isActive && 0 != _currentState.Count) { foreach (var state in _currentState) { state.Update(); } } }