public static bool FsmStateRespondsToEvent(SkillState state, SkillEvent fsmEvent) { if (SkillEvent.IsNullOrEmpty(fsmEvent)) { return(false); } SkillTransition[] globalTransitions = state.get_Fsm().get_GlobalTransitions(); for (int i = 0; i < globalTransitions.Length; i++) { SkillTransition fsmTransition = globalTransitions[i]; if (fsmTransition.get_EventName() == fsmEvent.get_Name()) { bool result = true; return(result); } } SkillTransition[] transitions = state.get_Transitions(); for (int j = 0; j < transitions.Length; j++) { SkillTransition fsmTransition2 = transitions[j]; if (fsmTransition2.get_EventName() == fsmEvent.get_Name()) { bool result = true; return(result); } } return(false); }
public static GUIContent GetEventLabel(SkillTransition transition) { SkillEditorContent.EventLabel.set_text("..."); SkillEditorContent.EventLabel.set_tooltip(""); if (!SkillEvent.IsNullOrEmpty(transition.get_FsmEvent())) { SkillEditorContent.EventLabel.set_text(transition.get_FsmEvent().get_Name()); } return(SkillEditorContent.EventLabel); }
public void SelectEvent(SkillEvent fsmEvent, bool syncSelection = true) { if (syncSelection) { GlobalEventsWindow.SyncSelection(fsmEvent); } this.selectedEvent = fsmEvent; if (SkillEvent.IsNullOrEmpty(fsmEvent)) { this.newEventName = ""; return; } this.newEventName = ((!fsmEvent.get_IsSystemEvent()) ? fsmEvent.get_Name() : ""); SkillEditor.Repaint(true); }
private static void CheckForEventErrors(SkillEvent fsmEvent) { if (SkillEvent.IsNullOrEmpty(fsmEvent)) { return; } SkillEventTarget fsmEventTarget = FsmErrorChecker.fsmEventTargetContextGlobal; if (FsmErrorChecker.fsmEventTargetContext != null) { fsmEventTarget = FsmErrorChecker.fsmEventTargetContext; } if (fsmEventTarget == null) { fsmEventTarget = new SkillEventTarget(); } Skill fsmTarget = Events.GetFsmTarget(FsmErrorChecker.checkingFsm, fsmEventTarget); switch (fsmEventTarget.target) { case 0: if (FsmErrorChecker.checkingState != null && !Events.FsmStateRespondsToEvent(FsmErrorChecker.checkingState, fsmEvent)) { FsmError fsmError = FsmErrorChecker.AddParameterError(Strings.get_FsmErrorChecker_InvalidEventError()); fsmError.Type = FsmError.ErrorType.missingTransitionEvent; fsmError.info = fsmEvent.get_Name(); } break; case 1: case 2: break; case 3: if (fsmTarget != null && !Events.FsmRespondsToEvent(fsmTarget, fsmEvent)) { FsmErrorChecker.AddParameterError(Strings.get_FsmErrorChecker_TargetFsmMissingEventError()); } return; case 4: FsmErrorChecker.CheckGlobalEvent(fsmEvent); return; default: return; } }
public static GenericMenu GenerateEventSelectionMenu(Skill fsm, SkillEvent selectedEvent, GenericMenu.MenuFunction2 selectFunction, GenericMenu.MenuFunction newFunction) { GenericMenu genericMenu = new GenericMenu(); bool flag = SkillEvent.IsNullOrEmpty(selectedEvent); genericMenu.AddItem(new GUIContent(Strings.get_Menu_None_Event()), flag, selectFunction, null); SkillEvent[] events = fsm.get_Events(); for (int i = 0; i < events.Length; i++) { SkillEvent fsmEvent = events[i]; flag = (fsmEvent == selectedEvent); genericMenu.AddItem(new GUIContent(fsmEvent.get_Name()), flag, selectFunction, fsmEvent); } genericMenu.AddSeparator(string.Empty); genericMenu.AddItem(new GUIContent(Strings.get_Menu_New_Event()), false, newFunction); return(genericMenu); }
private void DoEventEditor() { if (EditorWindow.get_focusedWindow() != SkillEditor.Window) { return; } SkillEditorGUILayout.LabelWidth(86f); bool flag = !SkillEvent.IsNullOrEmpty(this.selectedEvent); SkillEditorGUILayout.Divider(new GUILayoutOption[0]); if (flag && FsmEditorSettings.ShowHints) { GUILayout.Box(this.selectedEvent.get_IsSystemEvent() ? Strings.get_Hint_System_Events_cannot_be_renamed() : Strings.get_Hint_Use_Event_Browser_to_rename_globally(), SkillEditorStyles.HintBox, new GUILayoutOption[0]); } if (flag && this.selectedEvent.get_IsGlobal()) { SkillEditorGUILayout.ReadonlyTextField(SkillEditorContent.GlobalEventName, 82f, this.newEventName, new GUILayoutOption[0]); } else { if (!flag || !this.selectedEvent.get_IsSystemEvent()) { EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label(flag ? SkillEditorContent.EditEventNameLabel : SkillEditorContent.AddEventLabel, new GUILayoutOption[] { GUILayout.MaxWidth(80f) }); this.newEventName = EditorGUILayout.TextField(this.newEventName, new GUILayoutOption[0]); string text = SkillEditorGUILayout.FsmEventListPopup(); if (text != "") { this.AddEvent(text); return; } EditorGUILayout.EndHorizontal(); if (!flag && FsmEditorSettings.ShowHints) { GUILayout.Box(Strings.get_Tooltip_EventManager_Add_Event(), SkillEditorStyles.HintBox, new GUILayoutOption[0]); } } } if (flag) { bool flag2 = false; using (List <SkillEvent> .Enumerator enumerator = SkillEditor.SelectedFsm.ExposedEvents.GetEnumerator()) { while (enumerator.MoveNext()) { SkillEvent current = enumerator.get_Current(); if (current.get_Name() == this.selectedEvent.get_Name()) { flag2 = true; break; } } } bool flag3 = EditorGUILayout.Toggle(SkillEditorContent.EventInspectorLabel, flag2, new GUILayoutOption[0]); if (flag2 != flag3) { if (!flag3) { EditorCommands.RemoveExposedEvent(SkillEditor.SelectedFsm, this.selectedEvent); } else { EditorCommands.AddExposedEvent(SkillEditor.SelectedFsm, this.selectedEvent); } SkillEditor.SetFsmDirty(false, false); } if (FsmEditorSettings.ShowHints) { GUILayout.Box(Strings.get_Hint_EventManager_Expose_Events(), SkillEditorStyles.HintBox, new GUILayoutOption[0]); } } string text2 = this.ValidateEventName(flag); bool flag4 = string.IsNullOrEmpty(text2); if (!flag4) { GUILayout.Box(text2, SkillEditorStyles.ErrorBox, new GUILayoutOption[0]); } if (Event.get_current().get_isKey()) { if (flag4 && Keyboard.EnterKeyPressed()) { if (!flag) { this.AddEvent(this.newEventName); } else { this.RenameEvent(this.selectedEvent, this.newEventName); } Event.get_current().Use(); GUIUtility.ExitGUI(); return; } if (Event.get_current().get_keyCode() == 27) { this.Reset(); } } }
public static bool FsmRespondsToEvent(Skill fsm, SkillEvent fsmEvent) { return(fsm != null && !SkillEvent.IsNullOrEmpty(fsmEvent) && Events.FsmRespondsToEvent(fsm, fsmEvent.get_Name())); }