public void ChangeState <TState>(AFsm <T> fsm) where TState : AFsmState <T> { AFsm <T> fsmImplement = (AFsm <T>)fsm; if (fsmImplement == null) { throw new GameFrameworkException("FSM is invalid."); } fsmImplement.ChangeState <TState>(); }
public void ChangeState(AFsm <T> fsm, Type stateType) { AFsm <T> fsmImplement = (AFsm <T>)fsm; if (fsmImplement == null) { throw new GameFrameworkException("FSM is invalid."); } if (stateType == null) { throw new GameFrameworkException("State type is invalid."); } if (!typeof(AFsmState <T>).IsAssignableFrom(stateType)) { throw new GameFrameworkException(string.Format("State type '{0}' is invalid.", stateType.FullName)); } fsmImplement.ChangeState(stateType); }