public void EnterState(int stateId) { if (currentState != null && currentState.stateId == stateId) { // 状态相同 return; } FSMStateBase <T> targetState = stateDic.GetValue(stateId); if (currentState != null) { currentState.Exit(actor); } currentState = targetState; currentState.Enter(actor); }
public void RegisterState(FSMStateBase <T> state) { stateDic.Add(state.stateId, state); }