public static string CheckForValidEvent(SkillState state, string eventName) { if (state == null) { return("Invalid State!"); } if (string.IsNullOrEmpty(eventName)) { return(""); } SkillTransition[] globalTransitions = state.Fsm.GlobalTransitions; for (int i = 0; i < globalTransitions.Length; i++) { SkillTransition fsmTransition = globalTransitions[i]; if (fsmTransition.EventName == eventName) { string result = ""; return(result); } } SkillTransition[] transitions = state.Transitions; for (int j = 0; j < transitions.Length; j++) { SkillTransition fsmTransition2 = transitions[j]; if (fsmTransition2.EventName == eventName) { string result = ""; return(result); } } return("Fsm will not respond to Event: " + eventName); }
public void LogTransition(SkillState fromState, SkillTransition transition) { SkillLogEntry entry = new SkillLogEntry { Log = this, LogType = SkillLogType.Transition, State = fromState, Transition = transition }; this.AddEntry(entry, false); }
public int GetTransitionIndex(SkillTransition transition) { if (transition == null) { return(-1); } for (int i = 0; i < this.transitions.Length; i++) { SkillTransition fsmTransition = this.transitions[i]; if (fsmTransition == transition) { return(i); } } return(-1); }