public static FSM <T> Create(string name, T owner, List <FSMState <T> > states) { if (states == null || states.Count < 1) { Utility.DebugError("FSM owner is invalid"); return(null); } //从引用池获得同类 FSM <T> fsm = Facade.Instance.SpawnReference <FSM <T> >(); fsm.Name = name; fsm.Owner = owner; fsm.IsDestoryed = false; for (int i = 0; i < states.Count; i++) { if (states[i] == null) { Utility.DebugError("FSM owner is invalid"); return(null); } Type type = states[i].GetType(); if (fsm.HasState(type)) { Utility.DebugError("FSM state is already exist\n" + Utility.GetTypeFullName(states[i])); } else { fsm.fsmStateDict.Add(type, states[i]); states[i].OnInit(fsm); } } return(fsm); }
public static FSM <T> Create(string name, T owner, List <FSMState <T> > states) { if (states == null || states.Count < 1) { throw new ArgumentNullException("FSM owner is invalid"); } //从引用池获得同类 FSM <T> fsm = Facade.SpawnReference <FSM <T> >(); fsm.Name = name; fsm.Owner = owner; fsm.IsDestoryed = false; for (int i = 0; i < states.Count; i++) { if (states[i] == null) { throw new ArgumentNullException("FSM owner is invalid"); } Type type = states[i].GetType(); if (fsm.HasState(type)) { throw new ArgumentException("FSM state is is already exist " + Utility.Assembly.GetTypeFullName(states[i])); } else { states[i].OnInitialization(fsm); fsm.fsmStateDict.Add(type, states[i]); } } return(fsm); }
public static FSM <T> Create(string name, T owner, params FSMState <T>[] states) { if (states == null || states.Length < 1) { throw new ArgumentNullException("FSM owner is invalid"); } //从引用池获得同类 FSM <T> fsm = GameManager.GetModule <IReferencePoolManager>().Spawn <FSM <T> >(); fsm.Name = name; fsm.Owner = owner; fsm.IsDestoryed = false; for (int i = 0; i < states.Length; i++) { if (states[i] == null) { throw new ArgumentNullException("FSM owner is invalid"); } Type type = states[i].GetType(); if (fsm.HasState(type)) { throw new ArgumentException("FSM state is is already exist " + states[i].GetType().FullName); } else { states[i].OnInitialization(fsm); fsm.fsmStateDict.Add(type, states[i]); } } return(fsm); }