protected void AddState(IntelliFSMState newState) { if (states == null) { states = new Dictionary <string, IntelliFSMState>(); } newState.Init(); states.Add(newState.Name, newState); }
protected void SwitchState(string stateName) { IntelliFSMState result = null; if (states.TryGetValue(stateName, out result)) { if (result != null) { if (ExitState != null) { ExitState(); } prevState = curState; curState = result; foreach (var key in result.stateMethods.Keys) { Action a = null; if (result.stateMethods.TryGetValue(key, out a)) { if (a != null) { AssignDelegates(key, a); } } } if (EnterState != null) { EnterState(); } } } else { Debug.LogError("State: " + stateName + " Doesn't exist in IntelliFSM"); } }