/// <summary> 构造函数 </summary> public MainFsm(Type typeBool, Type tyFloat) { triggerSet = new HashSet <Enum>(); boolDict = new Dictionary <Enum, bool>(); floatDict = new Dictionary <Enum, float>(); tempTriggerList = new List <Enum>(); anyState = new AnyState(this); intoState = new IntoState(this, this); _currentNode = intoState; // --------------------------------- // 通过反射初始化FLoat和Bool对应的字典 var boolFields = typeBool.GetFields(BindingFlags.Static | BindingFlags.Public); foreach (var item in boolFields) { boolDict.Add((EBoolCondition)item.GetValue(null), false); } var floatFields = tyFloat.GetFields(BindingFlags.Static | BindingFlags.Public); foreach (var item in floatFields) { floatDict.Add((EFloatCondition)item.GetValue(null), 0); } }
// ---------------------- /// <summary> 构造函数 </summary> public SubFsm(MainFsm mainFsm, string name, FsmBase fsmBelongTo = null) { this._mainFsm = mainFsm; this._fsmBelongTo = fsmBelongTo ?? mainFsm; transitionList = new List <StateTransition>(); inState = new IntoState(this._mainFsm, this); outState = new OutState(this._mainFsm, this); _currentNode = inState; this._name = name ?? this.GetType().ToString(); mainFsm.AddNode(this); }