public void InsertState(FsmStateStruct <T> iStateFunc) { if (this.mFsmDict.ContainsKey(iStateFunc.mId)) { Debug.LogError("Fsm Contain two" + iStateFunc.mId + " state!"); return; } this.mFsmDict.Add(iStateFunc.mId, iStateFunc); }
public void SetCurrentState(T iId) { if (!this.mFsmDict.ContainsKey(iId)) { Debug.LogError("FsmDictionary do not contain " + iId + " state!"); return; } this.NextState = this.mFsmDict[iId]; if (this.CurrentState != null) { this.CurrentState.mExit(); this.LastState = this.CurrentState; } this.CurrentState = this.mFsmDict[iId]; if (this.LastState == null) { this.LastState = this.CurrentState; } this.CurrentState.mEnter(); }
public FSM() { this.CurrentState = null; this.LastState = null; this.mFsmDict = new Dictionary <T, FsmStateStruct <T> >(); }