//检测状态是否存在 public bool CheckFSMState(FSMBaseState state) { if (stateDictionary.ContainsKey(state.name)) { return(true); } else { return(false); } }
//删除一个状态 public void DeleteFSMState(FSMBaseState state) { if (state == null) { UtilityLog.LogError("状态为空"); return; } if (!stateDictionary.ContainsKey(state.name)) { UtilityLog.LogError("状态在状态机中不存在"); return; } stateDictionary.Remove(state.name); }
//添加一个状态 public void AddFSMState(FSMBaseState state) { if (state == null) { UtilityLog.LogError("状态为空"); return; } if (nowState == null) { //状态运行 nowState = state; nowState.StartState(); } if (stateDictionary.ContainsKey(state.name)) { UtilityLog.LogError("状态在状态机中已存在"); return; } stateDictionary.Add(state.name, state); }
public FSMEvent(string code, FSMBaseState from, FSMBaseState to) { this.code = code; this.from = from; this.to = to; }