public IFSM <T> CreateFSM <T>(string name, T owner, List <FSMState <T> > states) where T : class { if (!HasFSM(typeof(T))) { return(null); } Type type = typeof(T).GetType(); FSM <T> fsm = FSM <T> .Create(name, owner, states); fsmDict.Add(type, fsm); return(fsm); }
/// <summary> /// 创建状态机; /// Individual表示创建的为群组FSM或者独立FSM,二者拥有不同的容器 /// </summary> /// <typeparam name="T">拥有者类型</typeparam> /// <param name="name">状态机名称</param> /// <param name="owner">拥有者</param> /// <param name="Individual">是否为独立状态机</param> /// <param name="states">状态</param> /// <returns>创建成功后的状态机</returns> internal IFSM <T> CreateFSM <T>(string name, T owner, bool Individual, List <FSMState <T> > states) where T : class { Type type = typeof(T); FSM <T> fsm = default; if (Individual) { if (HasIndividualFSM(type)) { throw new ArgumentException("FSMManager : FSM is exists" + type.ToString()); } fsm = FSM <T> .Create(name, owner, states); fsmIndividualDict.Add(type, fsm); } else { fsm = FSM <T> .Create(name, owner, states); if (HasFSMSet(type)) { if (fsmSetDict[type].HasFSM(fsm)) { fsm.Shutdown(); } else { fsmSetDict[type].AddFSM(fsm); } } else { var fsmPool = new FSMPool(); fsmPool.AddFSM(fsm); fsmSetDict.Add(type, fsmPool); } } return(fsm); }