public void AddState(StateType id, SimpleFiniteState <StateType> state) { if (state == null) { return; } mStates[id] = state; }
public SimpleFiniteState <StateType> GetState(StateType id) { SimpleFiniteState <StateType> state = null; if (mStates.TryGetValue(id, out state)) { return(state); } return(null); }
public void SwitchToState(StateType id) { SimpleFiniteState <StateType> nextState = GetState(id); if (nextState == null) { //GameLog.LogError(string.Format("FSMachine.SwitchToState error,can not find {0} state", id)); return; } if (nextState == mCurrentState) { return; } if (mCurrentState != null) { mCurrentState.Exit(); } nextState.Enter(); mCurrentState = nextState; }