/// <summary> /// 注册状态机 /// </summary> /// <param name="fsm">状态机</param> public void RegisterFSM(FSM fsm) { if (fsm == null) { return; } if (!FSMs.ContainsKey(fsm.Name)) { FSMs.Add(fsm.Name, fsm); if (FSMGroups.ContainsKey(fsm.Group)) { FSMGroups[fsm.Group].Add(fsm); } else { FSMGroups.Add(fsm.Group, new List <FSM>()); FSMGroups[fsm.Group].Add(fsm); } } else { Log.Warning("注册状态机失败:已存在状态机 " + fsm.Name + " !"); } }
/// <summary> /// 通过名称获取状态机 /// </summary> /// <param name="name">状态机名称</param> /// <returns>状态机</returns> public FSM GetFSMByName(string name) { if (FSMs.ContainsKey(name)) { return(FSMs[name]); } else { throw new HTFrameworkException(HTFrameworkModule.FSM, "获取状态机失败:不存在状态机 " + name + " !"); } }
/// <summary> /// 通过名称获取状态机 /// </summary> /// <param name="name">状态机名称</param> /// <returns>状态机</returns> public FSM GetFSMByName(string name) { if (FSMs.ContainsKey(name)) { return(FSMs[name]); } else { return(null); } }
/// <summary> /// 移除已注册的状态机 /// </summary> /// <param name="fsm">状态机</param> public void UnRegisterFSM(FSM fsm) { if (FSMs.ContainsKey(fsm.Name)) { FSMs.Remove(fsm.Name); if (FSMGroups.ContainsKey(fsm.Group)) { FSMGroups[fsm.Group].Remove(fsm); } } else { throw new HTFrameworkException(HTFrameworkModule.FSM, "移除已注册的状态机失败:不存在状态机 " + fsm.Name + " !"); } }
/// <summary> /// 注册状态机 /// </summary> /// <param name="fsm">状态机</param> public void RegisterFSM(FSM fsm) { if (!FSMs.ContainsKey(fsm.Name)) { FSMs.Add(fsm.Name, fsm); if (FSMGroups.ContainsKey(fsm.Group)) { FSMGroups[fsm.Group].Add(fsm); } else { FSMGroups.Add(fsm.Group, new List <FSM>()); FSMGroups[fsm.Group].Add(fsm); } } else { throw new HTFrameworkException(HTFrameworkModule.FSM, "注册状态机失败:已存在状态机 " + fsm.Name + " !"); } }
/// <summary> /// 移除已注册的状态机 /// </summary> /// <param name="fsm">状态机</param> public void UnRegisterFSM(FSM fsm) { if (fsm == null) { return; } if (FSMs.ContainsKey(fsm.Name)) { FSMs.Remove(fsm.Name); if (FSMGroups.ContainsKey(fsm.Group)) { FSMGroups[fsm.Group].Remove(fsm); } } else { Log.Warning("移除已注册的状态机失败:不存在状态机 " + fsm.Name + " !"); } }
/// <summary> /// 是否存在指定的状态机 /// </summary> /// <param name="name">状态机名称</param> /// <returns>是否存在</returns> public bool IsExistFSM(string name) { return(FSMs.ContainsKey(name)); }