private static void CheckTransitionsForErrors(SkillState state) { List <string> list = new List <string>(); SkillTransition[] transitions = state.get_Transitions(); for (int i = 0; i < transitions.Length; i++) { SkillTransition fsmTransition = transitions[i]; if (FsmEditorSettings.CheckForTransitionMissingEvent && string.IsNullOrEmpty(fsmTransition.get_EventName())) { FsmErrorChecker.AddError(state, fsmTransition, Strings.get_FsmErrorChecker_TransitionMissingEventError()); } if (FsmEditorSettings.CheckForDuplicateTransitionEvent && list.Contains(fsmTransition.get_EventName())) { FsmErrorChecker.AddError(state, fsmTransition, Strings.get_FsmErrorChecker_DuplicateTransitionEventError()); } if (!string.IsNullOrEmpty(fsmTransition.get_EventName())) { list.Add(fsmTransition.get_EventName()); } if (FsmEditorSettings.CheckForTransitionMissingTarget && string.IsNullOrEmpty(fsmTransition.get_ToState())) { FsmErrorChecker.AddError(state, fsmTransition, Strings.get_FsmErrorChecker_TransitionMissingTargetError()); } if (state.get_Fsm() != null) { SkillEvent fsmEvent = fsmTransition.get_FsmEvent(); if (fsmEvent != null && fsmEvent.get_IsSystemEvent()) { FsmErrorChecker.CheckSystemEventsForErrors(state, fsmTransition, fsmEvent); } } } }
private void SelectEvent(SkillEvent fsmEvent) { if (Event.get_current() != null) { GUIUtility.set_keyboardControl(0); } if (fsmEvent == null) { return; } this.newEventName = ((!fsmEvent.get_IsSystemEvent()) ? fsmEvent.get_Name() : ""); this.selectedEvent = fsmEvent; SkillEditor.EventManager.SelectEvent(fsmEvent, false); }
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 void DoEventLine(SkillEvent fsmEvent) { int eventUseCount = SkillSearch.GetEventUseCount(SkillEditor.SelectedFsm, fsmEvent.get_Name()); GUILayout.BeginHorizontal((this.selectedEvent != null && fsmEvent.get_Name() == this.selectedEvent.get_Name()) ? SkillEditorStyles.SelectedEventBox : SkillEditorStyles.TableRowBox, new GUILayoutOption[0]); EditorGUI.BeginDisabledGroup(fsmEvent.get_IsSystemEvent()); bool flag = GUILayout.Toggle(fsmEvent.get_IsGlobal(), SkillEditorContent.GlobalEventTooltipLabel, SkillEditorStyles.TableRowCheckBox, new GUILayoutOption[] { GUILayout.MaxWidth(17f), GUILayout.MinWidth(17f) }); if (flag != fsmEvent.get_IsGlobal()) { SkillEditor.Builder.SetEventIsGlobal(SkillEditor.SelectedFsm, fsmEvent, flag); GlobalEventsWindow.ResetView(); } EditorGUI.EndDisabledGroup(); GUIStyle gUIStyle = (this.selectedEvent != null && fsmEvent.get_Name() == this.selectedEvent.get_Name()) ? SkillEditorStyles.TableRowTextSelected : SkillEditorStyles.TableRowText; if (GUILayout.Button(fsmEvent.get_Name(), gUIStyle, new GUILayoutOption[] { GUILayout.MinWidth(244f) })) { this.SelectEvent(fsmEvent, true); GUIUtility.set_keyboardControl(0); if (Event.get_current().get_button() == 1 || EditorGUI.get_actionKey()) { this.GenerateStateListMenu(this.selectedEvent).ShowAsContext(); } } GUILayout.FlexibleSpace(); GUILayout.Label(eventUseCount.ToString(CultureInfo.get_CurrentCulture()), gUIStyle, new GUILayoutOption[0]); GUILayout.Space(5f); if (SkillEditorGUILayout.DeleteButton()) { EditorCommands.DeleteEvent(fsmEvent); this.Reset(); } GUILayout.EndHorizontal(); }
public void UpdateUseCount() { if (EditorApplication.get_isPlayingOrWillChangePlaymode()) { return; } this.usageCount.Clear(); this.unusedEvents.Clear(); using (List <SkillEvent> .Enumerator enumerator = SkillEvent.get_EventList().GetEnumerator()) { while (enumerator.MoveNext()) { SkillEvent current = enumerator.get_Current(); int num = GlobalEventsWindow.CountEventUsage(current); this.usageCount.Add(current, num); if (num == 0 && !current.get_IsSystemEvent()) { this.unusedEvents.Add(current); } } } }
private void DoEventLine(SkillEvent fsmEvent) { int num; this.usageCount.TryGetValue(fsmEvent, ref num); if (num == 0 && FsmEditorSettings.HideUnusedEvents) { return; } GUILayout.BeginHorizontal((this.selectedEvent != null && fsmEvent.get_Name() == this.selectedEvent.get_Name()) ? SkillEditorStyles.SelectedEventBox : SkillEditorStyles.TableRowBox, new GUILayoutOption[0]); EditorGUI.BeginDisabledGroup(fsmEvent.get_IsSystemEvent()); bool flag = GUILayout.Toggle(fsmEvent.get_IsGlobal(), new GUIContent("", Strings.get_Label_Global()), SkillEditorStyles.TableRowCheckBox, new GUILayoutOption[] { GUILayout.MaxWidth(17f), GUILayout.MinWidth(17f) }); if (flag != fsmEvent.get_IsGlobal()) { SkillEditor.Builder.SetEventIsGlobal(null, fsmEvent, flag); } EditorGUI.EndDisabledGroup(); GUIStyle gUIStyle = (this.selectedEvent != null && fsmEvent.get_Name() == this.selectedEvent.get_Name()) ? SkillEditorStyles.TableRowTextSelected : SkillEditorStyles.TableRowText; if (GUILayout.Button(fsmEvent.get_Name(), gUIStyle, new GUILayoutOption[] { GUILayout.MinWidth(base.get_position().get_width() - 100f) })) { this.SelectEvent(fsmEvent); if (Event.get_current().get_button() == 1 || EditorGUI.get_actionKey()) { this.GenerateUsageContextMenu(this.selectedEvent).ShowAsContext(); } if (EditorApplication.get_timeSinceStartup() - this.clickTime < 0.3) { this.AddSelectedEventToState(); } this.clickTime = EditorApplication.get_timeSinceStartup(); } GUILayout.FlexibleSpace(); GUILayout.Label(num.ToString(CultureInfo.get_CurrentCulture()), gUIStyle, new GUILayoutOption[0]); GUILayout.Space(10f); EditorGUI.BeginDisabledGroup(fsmEvent.get_IsSystemEvent()); if (SkillEditorGUILayout.DeleteButton() && Dialogs.YesNoDialog(Strings.get_Dialog_Delete_Event(), string.Format(Strings.get_Dialog_Delete_Event_Are_you_sure(), (num > 0) ? string.Concat(new object[] { "\n\n", Strings.get_Dialog_Delete_Event_Used_By(), num, (num > 1) ? Strings.get_Label_Postfix_FSMs_Plural() : Strings.get_Label_Postfix_FSM() }) : ""))) { EditorCommands.DeleteEventFromAll(fsmEvent); SkillEditor.EventManager.Reset(); SkillEvent.RemoveEventFromEventList(fsmEvent); if (fsmEvent.get_IsGlobal()) { SkillEvent.get_globalEvents().RemoveAll((string r) => r == fsmEvent.get_Name()); SkillEditor.SaveGlobals(); } this.BuildFilteredList(); base.Repaint(); } EditorGUI.EndDisabledGroup(); GUILayout.EndHorizontal(); }