public void ChangeState(Type stateType) { if (currentState == null) { Utility.DebugError("Current state is invalid"); } FSMState <T> state = null; state = GetState(state.GetType()); if (state == null) { Utility.DebugError("FSM" + currentState.ToString() + " can not change state to " + state.ToString() + " which is not exist"); } currentState.OnExit(this); currentState = state; currentState.OnEnter(this); }
public void ChangeState(Type stateType) { if (currentState == null) { throw new ArgumentNullException("Current state is invalid"); } FSMState <T> state = null; //state = GetState(state.GetType()); state = GetState(stateType); if (state == null) { throw new ArgumentNullException("FSM" + currentState.ToString() + " can not change state to " + state.ToString() + " which is not exist"); } currentState.OnExit(this); currentState = state; currentState.OnEnter(this); }