public void StartDefault() { if (IsRunning) { return; } if (defaultState == null) { return; } Type type = defaultState.GetType(); if (!typeof(FSMState <T>).IsAssignableFrom(type)) { throw new ArgumentException("State type is invalid" + type.FullName); } FSMState <T> state = GetState(type); if (state == null) { return; } currentState = state; currentState.OnEnter(this); }
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 bool HasState(FSMState <T> state) { return(HasState(state.GetType())); }