コード例 #1
0
        private static void CheckSystemEventsForErrors(SkillState state, SkillTransition transition, SkillEvent fsmEvent)
        {
            GameObject gameObject = state.get_Fsm().get_GameObject();

            if (gameObject == null)
            {
                return;
            }
            if (FsmEditorSettings.CheckForMouseEventErrors && fsmEvent.get_Name().Contains("MOUSE") && gameObject.GetComponent <Collider>() == null && gameObject.GetComponent <GUIElement>() == null)
            {
                FsmErrorChecker.AddError(state, transition, Strings.get_FsmErrorChecker_MouseEventsNeedCollider());
            }
            if ((FsmEditorSettings.CheckForCollisionEventErrors && fsmEvent.get_Name().Contains("COLLISION")) || fsmEvent.get_Name().Contains("TRIGGER"))
            {
                if (fsmEvent.get_Name().Contains("2D"))
                {
                    if (gameObject.GetComponent <Collider2D>() == null && gameObject.GetComponent <Rigidbody2D>() == null)
                    {
                        FsmErrorChecker.AddError(state, transition, Strings.get_FsmErrorChecker_CollisionEventsNeedCollider2D());
                    }
                }
                else
                {
                    if (gameObject.GetComponent <Collider>() == null && gameObject.GetComponent <Rigidbody>() == null)
                    {
                        FsmErrorChecker.AddError(state, transition, Strings.get_FsmErrorChecker_CollisionEventsNeedCollider());
                    }
                }
            }
            if (FsmEditorSettings.CheckForCollisionEventErrors && fsmEvent.get_Name().Contains("CONTROLLER COLLIDER") && gameObject.GetComponent <CharacterController>() == null)
            {
                FsmErrorChecker.AddError(state, transition, Strings.get_FsmErrorChecker_ControllerCollisionEventsNeedController());
            }
        }
コード例 #2
0
ファイル: Events.cs プロジェクト: ihaiucom/ihaiu.SkillEditor
 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);
 }
コード例 #3
0
 private void UpdateUnusedEvents()
 {
     this.unusedEvents.Clear();
     SkillEvent[] events = this.fsm.get_Events();
     for (int i = 0; i < events.Length; i++)
     {
         SkillEvent fsmEvent = events[i];
         if (this.GetEventUseCount(fsmEvent.get_Name()) == 0)
         {
             this.unusedEvents.Add(fsmEvent.get_Name());
         }
     }
 }
コード例 #4
0
 private int CompareEventsByUseCount(SkillEvent event1, SkillEvent event2)
 {
     if (event1 == null)
     {
         if (event2 == null)
         {
             return(0);
         }
         return(-1);
     }
     else
     {
         if (event2 == null)
         {
             return(1);
         }
         int eventUseCount = SkillSearch.GetEventUseCount(SkillEditor.SelectedFsm, event1.get_Name());
         int num           = SkillSearch.GetEventUseCount(SkillEditor.SelectedFsm, event2.get_Name()).CompareTo(eventUseCount);
         if (num == 0)
         {
             return(string.Compare(event1.get_Name(), event2.get_Name(), 0));
         }
         return(num);
     }
 }
コード例 #5
0
        private static int CountEventUsage(SkillEvent fsmEvent)
        {
            if (fsmEvent == null)
            {
                return(0);
            }
            int num = 0;

            using (List <Skill> .Enumerator enumerator = SkillEditor.FsmList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Skill        current = enumerator.get_Current();
                    SkillEvent[] events  = current.get_Events();
                    for (int i = 0; i < events.Length; i++)
                    {
                        SkillEvent fsmEvent2 = events[i];
                        if (fsmEvent.get_Name() == fsmEvent2.get_Name())
                        {
                            num++;
                            break;
                        }
                    }
                }
            }
            return(num);
        }
コード例 #6
0
 private static bool IsEventUsedInField(Type fieldType, object fieldValue, string eventName)
 {
     if (fieldValue == null)
     {
         return(false);
     }
     if (fieldType == typeof(SkillEvent))
     {
         SkillEvent fsmEvent = (SkillEvent)fieldValue;
         return(eventName == fsmEvent.get_Name());
     }
     if (fieldType.get_IsArray())
     {
         Array array       = (Array)fieldValue;
         Type  elementType = fieldType.GetElementType();
         if (elementType == typeof(SkillEvent))
         {
             for (int i = 0; i < array.get_Length(); i++)
             {
                 if (SkillInfo.IsEventUsedInField(elementType, array.GetValue(i), eventName))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
コード例 #7
0
        public static string FsmEventListPopup()
        {
            int indentLevel = EditorGUI.get_indentLevel();

            EditorGUI.set_indentLevel(0);
            List <string> list = new List <string>();

            using (List <SkillEvent> .Enumerator enumerator = SkillEvent.get_EventList().GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    SkillEvent current = enumerator.get_Current();
                    list.Add(current.get_Name());
                }
            }
            int num = EditorGUILayout.Popup(-1, list.ToArray(), new GUILayoutOption[]
            {
                GUILayout.MaxWidth(20f)
            });

            EditorGUI.set_indentLevel(indentLevel);
            if (num <= 0)
            {
                return("");
            }
            return(list.get_Item(num));
        }
コード例 #8
0
        public static void SanityCheckEventList(Skill fsm)
        {
            bool flag = false;
            List <SkillEvent> list = new List <SkillEvent>();

            SkillEvent[] events = fsm.get_Events();
            for (int i = 0; i < events.Length; i++)
            {
                SkillEvent fsmEvent = events[i];
                if (!SkillEvent.EventListContainsEvent(list, fsmEvent.get_Name()))
                {
                    list.Add(fsmEvent);
                }
                else
                {
                    flag = true;
                    Debug.LogError(string.Format(Strings.get_Error_Duplicate_Event_Found__(), fsmEvent.get_Name()));
                }
            }
            if (flag)
            {
                fsm.set_Events(list.ToArray());
                SkillEditor.SetFsmDirty(fsm, false, false, true);
            }
        }
コード例 #9
0
ファイル: Menus.cs プロジェクト: ihaiucom/ihaiu.SkillEditor
 public static void AddCategorizedEventMenuItem(ref GenericMenu menu, string category, SkillEvent fsmEvent)
 {
     if (category != "")
     {
         category += '/';
     }
     menu.AddItem(new GUIContent(category + fsmEvent.get_Name()), SkillEditor.SelectedTransition.get_FsmEvent() == fsmEvent, new GenericMenu.MenuFunction2(FsmGraphView.ContextMenuSelectGlobalEvent), fsmEvent);
 }
コード例 #10
0
        private GenericMenu GenerateUsageContextMenu(SkillEvent fsmEvent)
        {
            this.UpdateUseCount();
            GenericMenu genericMenu = new GenericMenu();
            int         num;

            this.usageCount.TryGetValue(fsmEvent, ref num);
            if (num == 0)
            {
                genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_No_FSMs_Use_This_Event()));
                genericMenu.AddSeparator("");
                if (SkillEditor.SelectedFsm == null || SkillEditor.SelectedFsm.HasEvent(this.selectedEvent.get_Name()))
                {
                    genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_Add_Event_to_FSM()));
                }
                else
                {
                    genericMenu.AddItem(new GUIContent(Strings.get_Menu_Add_Event_to_FSM()), false, new GenericMenu.MenuFunction(this.AddSelectedEventToState));
                }
                return(genericMenu);
            }
            List <string> list = new List <string>();

            using (List <Skill> .Enumerator enumerator = SkillEditor.FsmList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Skill current = enumerator.get_Current();
                    if (current != null && current.get_OwnerObject() != null)
                    {
                        SkillEvent[] events = current.get_Events();
                        for (int i = 0; i < events.Length; i++)
                        {
                            SkillEvent fsmEvent2 = events[i];
                            if (fsmEvent2.get_Name() == fsmEvent.get_Name())
                            {
                                string text = Labels.GenerateUniqueLabel(list, Labels.GetFullFsmLabel(current));
                                genericMenu.AddItem(new GUIContent(text), SkillEditor.SelectedFsm == current, new GenericMenu.MenuFunction2(EditorCommands.SelectFsm), current);
                                list.Add(text);
                            }
                        }
                    }
                }
            }
            genericMenu.AddSeparator("");
            if (SkillEditor.SelectedFsm == null || SkillEditor.SelectedFsm.HasEvent(this.selectedEvent.get_Name()))
            {
                genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_Add_Event_to_FSM()));
            }
            else
            {
                genericMenu.AddItem(new GUIContent(Strings.get_Menu_Add_Event_to_FSM()), false, new GenericMenu.MenuFunction(this.AddSelectedEventToState));
            }
            return(genericMenu);
        }
コード例 #11
0
        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();
        }
コード例 #12
0
 private void RenameEvent(SkillEvent fsmEvent, string newName)
 {
     if (fsmEvent == null)
     {
         return;
     }
     if (fsmEvent.get_IsGlobal())
     {
         if (Dialogs.AreYouSure(Strings.get_Dialog_Rename_Event(), Strings.get_Dialog_Rename_Event_Are_you_sure()))
         {
             SkillEditor.Builder.RenameEvent(fsmEvent.get_Name(), newName);
         }
     }
     else
     {
         SkillEditor.Builder.RenameEvent(SkillEditor.SelectedFsm, fsmEvent.get_Name(), newName);
     }
     SkillEditor.SelectedFsm.set_Events(ArrayUtility.Sort <SkillEvent>(SkillEditor.SelectedFsm.get_Events()));
     this.Reset();
 }
コード例 #13
0
        private void BuildFilteredList()
        {
            SkillEvent.SanityCheckEventList();
            this.UpdateUseCount();
            List <SkillEvent> list;

            switch (this.searchBox.SearchMode)
            {
            case 0:
                list = new List <SkillEvent>(SkillEvent.get_EventList());
                break;

            case 1:
                list = Enumerable.ToList <SkillEvent>(Enumerable.Where <SkillEvent>(SkillEvent.get_EventList(), (SkillEvent p) => p.get_IsGlobal()));
                break;

            case 2:
                list = Enumerable.ToList <SkillEvent>(Enumerable.Where <SkillEvent>(SkillEvent.get_EventList(), (SkillEvent p) => !p.get_IsGlobal()));
                break;

            case 3:
                list = Enumerable.ToList <SkillEvent>(Enumerable.Where <SkillEvent>(SkillEvent.get_EventList(), (SkillEvent p) => p.get_IsSystemEvent()));
                break;

            default:
                list = new List <SkillEvent>(SkillEvent.get_EventList());
                break;
            }
            if (string.IsNullOrEmpty(this.searchString))
            {
                this.filteredEvents = new List <SkillEvent>(list);
                this.filteredEvents.Sort();
                return;
            }
            this.filteredEvents.Clear();
            string text = this.searchString.ToUpper();

            using (List <SkillEvent> .Enumerator enumerator = list.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    SkillEvent current = enumerator.get_Current();
                    if (current.get_Name().ToUpper().Contains(text))
                    {
                        this.filteredEvents.Add(current);
                    }
                }
            }
            this.filteredEvents.Sort();
        }
コード例 #14
0
 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);
 }
コード例 #15
0
ファイル: Events.cs プロジェクト: ihaiucom/ihaiu.SkillEditor
 public static bool EventListContainsEventName(List <SkillEvent> eventList, string fsmEventName)
 {
     using (List <SkillEvent> .Enumerator enumerator = eventList.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             SkillEvent current = enumerator.get_Current();
             if (current.get_Name() == fsmEventName)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
コード例 #16
0
 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);
 }
コード例 #17
0
        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;
            }
        }
コード例 #18
0
ファイル: Events.cs プロジェクト: ihaiucom/ihaiu.SkillEditor
        public static GUIContent[] GetEventNamesFromList(List <SkillEvent> eventList)
        {
            List <GUIContent> list = new List <GUIContent>();

            list.Add(new GUIContent(Strings.get_Label_None()));
            List <GUIContent> list2 = list;

            using (List <SkillEvent> .Enumerator enumerator = eventList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    SkillEvent current = enumerator.get_Current();
                    list2.Add(new GUIContent(current.get_Name()));
                }
            }
            return(list2.ToArray());
        }
コード例 #19
0
        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);
        }
コード例 #20
0
        private GenericMenu GenerateStateListMenu(SkillEvent fsmEvent)
        {
            GenericMenu genericMenu = new GenericMenu();

            if (SkillSearch.GetEventUseCount(SkillEditor.SelectedFsm, fsmEvent.get_Name()) == 0)
            {
                genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_Unused_Event()));
                return(genericMenu);
            }
            List <SkillState> list = SkillInfo.FindStatesUsingEvent(SkillEditor.SelectedFsm, fsmEvent.get_Name());

            using (List <SkillState> .Enumerator enumerator = list.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    SkillState current = enumerator.get_Current();
                    genericMenu.AddItem(new GUIContent(current.get_Name()), SkillEditor.SelectedState == current, new GenericMenu.MenuFunction2(EditorCommands.SelectState), current);
                }
            }
            return(genericMenu);
        }
コード例 #21
0
        public static SkillEvent EventPopup(GUIContent label, List <SkillEvent> eventList, SkillEvent selectedEvent)
        {
            GUIContent[] eventNamesFromList = Events.GetEventNamesFromList(eventList);
            string       text = (selectedEvent == null) ? null : selectedEvent.get_Name();
            int          num  = -1;
            int          num2 = 0;

            GUIContent[] array = eventNamesFromList;
            for (int i = 0; i < array.Length; i++)
            {
                GUIContent gUIContent = array[i];
                if (gUIContent.get_text() == text)
                {
                    num = num2;
                    break;
                }
                num2++;
            }
            int num3 = EditorGUILayout.Popup(label, num, eventNamesFromList, new GUILayoutOption[0]);

            if (num3 > 0)
            {
                string text2 = eventNamesFromList[num3].get_text();
                using (List <SkillEvent> .Enumerator enumerator = eventList.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        SkillEvent current = enumerator.get_Current();
                        if (current.get_Name() == text2)
                        {
                            return(current);
                        }
                    }
                }
                return(null);
            }
            return(null);
        }
コード例 #22
0
        public static string FsmEventPopup(GameObject gameObject, string fsmName)
        {
            int indentLevel = EditorGUI.get_indentLevel();

            EditorGUI.set_indentLevel(0);
            List <string> list = new List <string>();

            list.Add(Strings.get_Label_None());
            List <string> list2 = list;

            using (List <Skill> .Enumerator enumerator = SkillEditor.FsmList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Skill current = enumerator.get_Current();
                    if (current.get_GameObject() == gameObject && current.get_Name() == fsmName)
                    {
                        SkillEvent[] events = current.get_Events();
                        for (int i = 0; i < events.Length; i++)
                        {
                            SkillEvent fsmEvent = events[i];
                            list2.Add(fsmEvent.get_Name());
                        }
                    }
                }
            }
            int num = EditorGUILayout.Popup(-1, list2.ToArray(), new GUILayoutOption[]
            {
                GUILayout.MaxWidth(20f)
            });

            EditorGUI.set_indentLevel(indentLevel);
            if (num <= 0)
            {
                return("");
            }
            return(list2.get_Item(num));
        }
コード例 #23
0
ファイル: Events.cs プロジェクト: ihaiucom/ihaiu.SkillEditor
 public static bool FsmRespondsToEvent(Skill fsm, SkillEvent fsmEvent)
 {
     return(fsm != null && !SkillEvent.IsNullOrEmpty(fsmEvent) && Events.FsmRespondsToEvent(fsm, fsmEvent.get_Name()));
 }
コード例 #24
0
        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();
        }
コード例 #25
0
        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();
                }
            }
        }
コード例 #26
0
        public static void OnGUI()
        {
            EditorGUI.BeginChangeCheck();
            Skill fsm = SkillEditor.SelectedFsm;

            if (fsm == null)
            {
                GUILayout.FlexibleSpace();
                return;
            }
            if (!FsmInspector.isInitialized)
            {
                FsmInspector.isInitialized = true;
                FsmInspector.Init();
            }
            FsmInspector.scrollViewPosition = GUILayout.BeginScrollView(FsmInspector.scrollViewPosition, new GUILayoutOption[0]);
            EditorGUI.BeginChangeCheck();
            fsm.set_Name(EditorGUILayout.TextField(fsm.get_Name(), new GUILayoutOption[0]));
            if (EditorGUI.EndChangeCheck())
            {
                Labels.Update(fsm);
            }
            if (fsm.get_Owner() != null)
            {
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                SkillTemplate fsmTemplate = (SkillTemplate)EditorGUILayout.ObjectField(FsmInspector.SelectedTemplate, typeof(SkillTemplate), false, new GUILayoutOption[0]);
                if (fsmTemplate != FsmInspector.SelectedTemplate)
                {
                    FsmInspector.SelectTemplate(fsmTemplate);
                }
                if (GUILayout.Button(SkillEditorContent.BrowseTemplateButton, new GUILayoutOption[]
                {
                    GUILayout.MaxWidth(30f),
                    GUILayout.Height(16f)
                }))
                {
                    Templates.DoSelectTemplateMenu(FsmInspector.SelectedTemplate, new GenericMenu.MenuFunction(FsmInspector.ClearTemplate), new GenericMenu.MenuFunction2(FsmInspector.SelectTemplate));
                }
                GUILayout.EndHorizontal();
            }
            EditorGUI.BeginDisabledGroup(!Application.get_isPlaying() && SkillEditor.SelectedFsmUsesTemplate);
            if (fsm.get_Template() != null)
            {
                fsm = fsm.get_Template().fsm;
            }
            fsm.set_Description(SkillEditorGUILayout.TextAreaWithHint(fsm.get_Description(), Strings.get_Label_Description___(), new GUILayoutOption[]
            {
                GUILayout.MinHeight(80f)
            }));
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            fsm.set_DocUrl(SkillEditorGUILayout.TextFieldWithHint(fsm.get_DocUrl(), Strings.get_Tooltip_Documentation_Url(), new GUILayoutOption[0]));
            EditorGUI.BeginDisabledGroup(!string.IsNullOrEmpty(fsm.get_DocUrl()));
            if (SkillEditorGUILayout.HelpButton("Online Help"))
            {
                Application.OpenURL(fsm.get_DocUrl());
            }
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndHorizontal();
            EditorGUI.BeginDisabledGroup(!Application.get_isPlaying() && SkillEditor.SelectedFsmUsesTemplate);
            fsm.set_MaxLoopCountOverride(EditorGUILayout.IntField(SkillEditorContent.MaxLoopOverrideLabel, fsm.get_MaxLoopCountOverride(), new GUILayoutOption[0]));
            fsm.RestartOnEnable = GUILayout.Toggle(fsm.RestartOnEnable, SkillEditorContent.ResetOnDisableLabel, new GUILayoutOption[0]);
            EditorGUI.EndDisabledGroup();
            EditorGUI.EndDisabledGroup();
            fsm = SkillEditor.SelectedFsm;
            SkillEditorGUILayout.LightDivider(new GUILayoutOption[0]);
            GUILayout.Label(SkillEditorContent.FsmControlsLabel, EditorStyles.get_boldLabel(), new GUILayoutOption[0]);
            if (fsm.ExposedEvents.get_Count() + FsmInspector.fsmVariables.get_Count() == 0)
            {
                SkillEditorGUILayout.DisabledLabel(Strings.get_Label_None_In_Table());
            }
            else
            {
                SkillEditorGUILayout.LabelWidth(100f);
                int num = 0;
                for (int i = 0; i < FsmInspector.fsmVariables.get_Count(); i++)
                {
                    SkillVariable fsmVariable = FsmInspector.fsmVariables.get_Item(i);
                    if (fsmVariable.ShowInInspector)
                    {
                        int categoryID = fsmVariable.CategoryID;
                        if (categoryID > 0 && categoryID != num)
                        {
                            num = categoryID;
                            GUILayout.Label(SkillEditor.SelectedFsm.get_Variables().get_Categories()[categoryID], EditorStyles.get_boldLabel(), new GUILayoutOption[0]);
                            SkillEditorGUILayout.LightDivider(new GUILayoutOption[0]);
                        }
                        fsmVariable.DoInspectorGUI(SkillEditorContent.TempContent(fsmVariable.Name, fsmVariable.Name + ((!string.IsNullOrEmpty(fsmVariable.Tooltip)) ? (":\n" + fsmVariable.Tooltip) : "")), false);
                    }
                }
                using (List <SkillEvent> .Enumerator enumerator = fsm.ExposedEvents.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        SkillEvent current = enumerator.get_Current();
                        if (GUILayout.Button(current.get_Name(), new GUILayoutOption[0]))
                        {
                            fsm.Event(current);
                        }
                    }
                }
                if (GUI.get_changed())
                {
                    SkillEditor.RepaintAll();
                }
            }
            if (FsmEditorSettings.ShowHints)
            {
                GUILayout.Box(Strings.get_Hint_Expose_Events_and_Variables(), SkillEditorStyles.HintBox, new GUILayoutOption[0]);
            }
            SkillEditorGUILayout.LightDivider(new GUILayoutOption[0]);
            GUILayout.Label(SkillEditorContent.NetworkSyncLabel, EditorStyles.get_boldLabel(), new GUILayoutOption[0]);
            int num2 = 0;

            SkillBool[] boolVariables = fsm.get_Variables().get_BoolVariables();
            for (int j = 0; j < boolVariables.Length; j++)
            {
                SkillBool fsmBool = boolVariables[j];
                if (fsmBool.get_NetworkSync())
                {
                    GUILayout.Label(fsmBool.get_Name(), new GUILayoutOption[0]);
                    num2++;
                }
            }
            SkillFloat[] floatVariables = fsm.get_Variables().get_FloatVariables();
            for (int k = 0; k < floatVariables.Length; k++)
            {
                SkillFloat fsmFloat = floatVariables[k];
                if (fsmFloat.get_NetworkSync())
                {
                    GUILayout.Label(fsmFloat.get_Name(), new GUILayoutOption[0]);
                    num2++;
                }
            }
            SkillInt[] intVariables = fsm.get_Variables().get_IntVariables();
            for (int l = 0; l < intVariables.Length; l++)
            {
                SkillInt fsmInt = intVariables[l];
                if (fsmInt.get_NetworkSync())
                {
                    GUILayout.Label(fsmInt.get_Name(), new GUILayoutOption[0]);
                    num2++;
                }
            }
            SkillQuaternion[] quaternionVariables = fsm.get_Variables().get_QuaternionVariables();
            for (int m = 0; m < quaternionVariables.Length; m++)
            {
                SkillQuaternion fsmQuaternion = quaternionVariables[m];
                if (fsmQuaternion.get_NetworkSync())
                {
                    GUILayout.Label(fsmQuaternion.get_Name(), new GUILayoutOption[0]);
                    num2++;
                }
            }
            SkillVector3[] vector3Variables = fsm.get_Variables().get_Vector3Variables();
            for (int n = 0; n < vector3Variables.Length; n++)
            {
                SkillVector3 fsmVector = vector3Variables[n];
                if (fsmVector.get_NetworkSync())
                {
                    GUILayout.Label(fsmVector.get_Name(), new GUILayoutOption[0]);
                    num2++;
                }
            }
            if (num2 == 0)
            {
                SkillEditorGUILayout.DisabledLabel(Strings.get_Label_None_In_Table());
            }
            if (FsmEditorSettings.ShowHints)
            {
                GUILayout.Box(Strings.get_Hint_Network_Sync_Variables(), SkillEditorStyles.HintBox, new GUILayoutOption[0]);
            }
            SkillEditorGUILayout.LightDivider(new GUILayoutOption[0]);
            GUILayout.Label("Debug", EditorStyles.get_boldLabel(), new GUILayoutOption[0]);
            fsm.set_ShowStateLabel(GUILayout.Toggle(fsm.get_ShowStateLabel(), SkillEditorContent.ShowStateLabelsLabel, new GUILayoutOption[0]));
            fsm.EnableBreakpoints = GUILayout.Toggle(fsm.EnableBreakpoints, SkillEditorContent.EnableBreakpointsLabel, new GUILayoutOption[0]);
            fsm.EnableDebugFlow   = GUILayout.Toggle(fsm.EnableDebugFlow, SkillEditorContent.EnableDebugFlowLabel, new GUILayoutOption[0]);
            SkillEditorGUILayout.LightDivider(new GUILayoutOption[0]);
            GUILayout.Label("Experimental", EditorStyles.get_boldLabel(), new GUILayoutOption[0]);
            EditorGUILayout.HelpBox(Strings.get_Help_Experimental_Warning(), 0);
            fsm.set_KeepDelayedEventsOnStateExit(GUILayout.Toggle(fsm.get_KeepDelayedEventsOnStateExit(), SkillEditorContent.KeepDelayedEvents, new GUILayoutOption[0]));
            fsm.set_ManualUpdate(GUILayout.Toggle(fsm.get_ManualUpdate(), SkillEditorContent.ManualUpdate, new GUILayoutOption[0]));
            GUILayout.EndScrollView();
            EventType arg_641_0 = Event.get_current().get_type();

            if (EditorGUI.EndChangeCheck())
            {
                SkillEditor.SetFsmDirty(false, false);
            }
            if (Event.get_current().get_type() == null)
            {
                GUIUtility.set_keyboardControl(0);
            }
            SkillEditorGUILayout.LightDivider(new GUILayoutOption[0]);
            EditorGUI.BeginDisabledGroup(true);
            GUILayout.Label("Data Version: " + fsm.get_DataVersion(), EditorStyles.get_miniLabel(), new GUILayoutOption[0]);
            EditorGUI.EndDisabledGroup();
            SkillEditorGUILayout.LockFsmGUI(fsm);
        }