예제 #1
0
        private void HandleKeyboardInput()
        {
            this.prevEntry = null;
            int controlID = GUIUtility.GetControlID(1);

            if (Event.get_current().GetTypeForControl(controlID) == 4)
            {
                KeyCode keyCode = Event.get_current().get_keyCode();
                if (keyCode != 13)
                {
                    switch (keyCode)
                    {
                    case 272:
                        return;

                    case 273:
                        Event.get_current().Use();
                        this.SelectPreviousLogEntry();
                        GUIUtility.ExitGUI();
                        return;

                    case 274:
                        Event.get_current().Use();
                        this.SelectNextLogEntry();
                        GUIUtility.ExitGUI();
                        return;
                    }
                }
                return;
            }
        }
예제 #2
0
        private static SkillLogEntry FindPrevLogEntry(SkillLogEntry fromEntry, SkillLogType logType = 6)
        {
            if (fromEntry == null)
            {
                return(null);
            }
            SkillLog log = fromEntry.get_Log();

            if (log == null || log.get_Entries() == null)
            {
                return(null);
            }
            SkillLogEntry result = null;

            using (List <SkillLogEntry> .Enumerator enumerator = log.get_Entries().GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    SkillLogEntry current = enumerator.get_Current();
                    if (current == fromEntry)
                    {
                        break;
                    }
                    if (current.get_LogType() == logType)
                    {
                        result = current;
                    }
                }
            }
            return(result);
        }
예제 #3
0
 public static void SelectLogEntry(SkillLogEntry logEntry, bool updateTime = true)
 {
     if (logEntry != null)
     {
         DebugFlow.SelectedLog           = logEntry.get_Log();
         DebugFlow.SelectedLogEntry      = logEntry;
         DebugFlow.DebugState            = logEntry.get_State();
         DebugFlow.SelectedLogEntryIndex = logEntry.GetIndex();
         if (updateTime)
         {
             DebugFlow.CurrentDebugTime  = logEntry.get_Time();
             DebugFlow.CurrentDebugFrame = logEntry.get_FrameCount();
         }
         SkillEditor.SelectState(logEntry.get_State(), true);
         if (logEntry.get_Action() != null)
         {
             SkillEditor.SelectAction(logEntry.get_Action(), true);
         }
         if (FsmEditorSettings.EnableDebugFlow && DebugFlow.SelectedLog.get_Fsm().EnableDebugFlow&& DebugFlow.SelectedLogEntryIndex < DebugFlow.lastEnterIndex)
         {
             DebugFlow.RestoreNearestVariables(logEntry);
         }
         if (DebugFlow.LogEntrySelected != null)
         {
             DebugFlow.LogEntrySelected(logEntry);
         }
         SkillEditor.Repaint(true);
     }
 }
예제 #4
0
 private int ExtraRows(SkillLogEntry entry)
 {
     if (this.ShowSentBy(entry) || this.ShowEventTarget(entry) || this.ShowHitGameObject(entry))
     {
         return(1);
     }
     return(0);
 }
예제 #5
0
 private static void OnClickSentBy(SkillLogEntry entry)
 {
     if (entry.get_SentByState() != null)
     {
         SkillEditor.SelectFsm(entry.get_SentByState().get_Fsm());
         SkillEditor.SelectState(entry.get_SentByState(), true);
         SkillEditor.SelectAction(entry.get_Action(), true);
     }
 }
예제 #6
0
 public static void Cleanup()
 {
     DebugFlow.variablesCache.Clear();
     DebugFlow.globalVariablesCache = null;
     DebugFlow.SelectedLog          = null;
     DebugFlow.SelectedLogEntry     = null;
     DebugFlow.DebugState           = null;
     DebugFlow.lastEnter            = null;
 }
예제 #7
0
        private static string GetEventTargetLabel(SkillLogEntry entry)
        {
            SkillEventTarget eventTarget = entry.get_EventTarget();

            switch (eventTarget.target)
            {
            case 0:
                return(null);

            case 1:
            {
                GameObject ownerDefaultTarget = SkillEditor.SelectedFsm.GetOwnerDefaultTarget(eventTarget.gameObject);
                if (!(ownerDefaultTarget != null))
                {
                    return(" GameObject: None");
                }
                return(" GameObject: " + ownerDefaultTarget.get_name());
            }

            case 2:
            {
                GameObject ownerDefaultTarget = SkillEditor.SelectedFsm.GetOwnerDefaultTarget(eventTarget.gameObject);
                if (!(ownerDefaultTarget != null))
                {
                    return(" GameObjectFSM: None");
                }
                return(string.Concat(new object[]
                    {
                        " GameObjectFSM: ",
                        ownerDefaultTarget.get_name(),
                        " ",
                        eventTarget.fsmName
                    }));
            }

            case 3:
                if (!(eventTarget.fsmComponent != null))
                {
                    return(" FsmComponent: None");
                }
                return(" FsmComponent: " + Labels.GetFullFsmLabel(eventTarget.fsmComponent.get_Fsm()));

            case 4:
                return(" BroadcastAll");

            case 5:
                return(" Host: " + entry.get_State().get_Fsm().get_Host().get_Name());

            case 6:
                return(" SubFSMs");

            default:
                return(null);
            }
        }
예제 #8
0
 private void SelectLogEntry(SkillLogEntry entry)
 {
     if (entry == null)
     {
         return;
     }
     if (FsmEditorSettings.LogPauseOnSelect && !EditorApplication.get_isPaused())
     {
         EditorApplication.set_isPaused(true);
     }
     DebugFlow.SelectLogEntry(entry, true);
     this.autoScroll = true;
 }
예제 #9
0
 public static void SyncFsmLog(Skill fsm)
 {
     if (fsm == null)
     {
         return;
     }
     DebugFlow.SelectedLog = fsm.get_MyLog();
     if (DebugFlow.Active && DebugFlow.SelectedLog != null && DebugFlow.SelectedLog.get_Entries() != null)
     {
         DebugFlow.SelectMostRecentLogEntry(DebugFlow.CurrentDebugFrame);
         DebugFlow.lastEnter      = DebugFlow.SelectedLogEntry;
         DebugFlow.lastEnterIndex = DebugFlow.SelectedLog.get_Entries().IndexOf(DebugFlow.lastEnter);
     }
 }
예제 #10
0
        private void DoTimelineBar(Skill fsm, Rect area)
        {
            if (!Application.get_isPlaying())
            {
                return;
            }
            if (fsm == null)
            {
                return;
            }
            SkillLog myLog = fsm.get_MyLog();

            if (myLog == null || myLog.get_Entries() == null)
            {
                return;
            }
            GUI.BeginGroup(area);
            float      startTime = 0f;
            SkillState fsmState  = null;

            for (int i = 0; i < myLog.get_Entries().get_Count(); i++)
            {
                SkillLogEntry fsmLogEntry = myLog.get_Entries().get_Item(i);
                if (fsmLogEntry.get_LogType() == 5)
                {
                    if (fsmLogEntry.get_Time() > this.timelineControl.VisibleRangeStart)
                    {
                        this.DrawTimelineBar(startTime, fsmLogEntry.get_Time(), fsmState);
                    }
                    fsmState = null;
                }
                if (fsmLogEntry.get_LogType() == 6)
                {
                    if (fsmLogEntry.get_Time() > this.timelineControl.VisibleRangeEnd)
                    {
                        GUI.EndGroup();
                        return;
                    }
                    fsmState  = fsmLogEntry.get_State();
                    startTime = fsmLogEntry.get_Time();
                }
                SkillLogType arg_AE_0 = fsmLogEntry.get_LogType();
                SkillLogType arg_B8_0 = fsmLogEntry.get_LogType();
            }
            if (fsmState != null)
            {
                this.DrawTimelineBar(startTime, SkillTime.get_RealtimeSinceStartup(), fsmState);
            }
            GUI.EndGroup();
        }
예제 #11
0
        private float CalculateEntryHeight(SkillLogEntry entry)
        {
            if (!this.EntryIsVisible(entry))
            {
                return(0f);
            }
            float num = 20f;

            if (entry.get_LogType() == 6)
            {
                num += 2f;
            }
            return(num + 20f * (float)this.ExtraRows(entry));
        }
예제 #12
0
 private static void RestoreNearestVariables(SkillLogEntry logEntry)
 {
     if (logEntry == null)
     {
         return;
     }
     if (logEntry.get_LogType() == 6 || logEntry.get_LogType() == 5)
     {
         DebugFlow.RestoreVariables(logEntry);
         return;
     }
     if (logEntry.get_Event() == SkillEvent.get_Finished())
     {
         SkillLogEntry fsmLogEntry = DebugFlow.FindNextLogEntry(logEntry, new SkillLogType[]
         {
             5
         });
         if (fsmLogEntry != null)
         {
             DebugFlow.RestoreVariables(fsmLogEntry);
             return;
         }
     }
     else
     {
         if (DebugFlow.SelectedLogEntryIndex == 0)
         {
             SkillLogEntry fsmLogEntry2 = DebugFlow.FindNextLogEntry(logEntry, new SkillLogType[]
             {
                 6
             });
             if (fsmLogEntry2 != null)
             {
                 DebugFlow.RestoreVariables(fsmLogEntry2);
                 return;
             }
         }
         else
         {
             SkillLogEntry fsmLogEntry3 = DebugFlow.FindPrevLogEntry(logEntry, 6);
             if (fsmLogEntry3 != null)
             {
                 DebugFlow.RestoreVariables(fsmLogEntry3);
             }
         }
     }
 }
예제 #13
0
        private void UpdateLayout()
        {
            bool  flag = this.ScrollViewIsAtBottom();
            float num  = this.GetEntryPosition(this.entryHeights.get_Count());
            float num2 = num;

            while (this.entryHeights.get_Count() < SkillLogger.selectedLog.get_Entries().get_Count())
            {
                SkillLogEntry entry = SkillLogger.selectedLog.get_Entries().get_Item(this.entryHeights.get_Count());
                num += this.CalculateEntryHeight(entry);
                this.entryHeights.Add(num);
                this.updateVisibility = true;
            }
            if (flag)
            {
                this.scrollPosition.y = this.scrollPosition.y + (this.GetEntryPosition(this.entryHeights.get_Count()) - num2);
            }
        }
예제 #14
0
        private void DoLogView()
        {
            if (SkillLogger.selectedLog == null || SkillLogger.selectedLog.get_Entries() == null || this.entryHeights.get_Count() != SkillLogger.selectedLog.get_Entries().get_Count())
            {
                GUILayout.FlexibleSpace();
                return;
            }
            this.currentState    = null;
            this.numEntriesDrawn = 0;
            Vector2 vector = GUILayout.BeginScrollView(this.scrollPosition, false, true, new GUILayoutOption[0]);

            if (vector != this.scrollPosition)
            {
                this.scrollPosition   = vector;
                this.updateVisibility = true;
            }
            if (SkillLogger.selectedLog != null && SkillLogger.selectedLog.get_Entries() != null)
            {
                float entryPosition = this.GetEntryPosition(this.firstVisibleEntry);
                GUILayout.Space(entryPosition);
                for (int i = this.firstVisibleEntry; i < this.lastVisibleEntry; i++)
                {
                    SkillLogEntry fsmLogEntry = SkillLogger.selectedLog.get_Entries().get_Item(i);
                    this.DoLogLine(fsmLogEntry, i);
                    if (this.numEntriesDrawn > 0 && this.eventType == 7 && fsmLogEntry == this.selectedEntry)
                    {
                        this.selectedRect = GUILayoutUtility.GetLastRect();
                        this.selectedRect.set_y(this.selectedRect.get_y() - this.scrollPosition.y);
                    }
                }
                if (this.lastVisibleEntry < this.entryHeights.get_Count())
                {
                    GUILayout.Space(this.GetEntryPosition(this.entryHeights.get_Count()) - this.entryHeights.get_Item(this.lastVisibleEntry));
                }
            }
            GUILayout.EndScrollView();
            if (this.eventType == 7)
            {
                this.scrollViewHeight = GUILayoutUtility.GetLastRect().get_height();
                this.DoAutoScroll();
            }
        }
예제 #15
0
        private static void RestoreVariables(SkillLogEntry logEntry)
        {
            if (logEntry == null)
            {
                Debug.Log("Bad Log Entry!");
                return;
            }
            Skill fsm = logEntry.get_Fsm();

            if (!fsm.EnableDebugFlow)
            {
                return;
            }
            if (fsm == null)
            {
                Debug.Log("Fsm == null!!");
                return;
            }
            if (logEntry.get_FsmVariablesCopy() != null)
            {
                fsm.get_Variables().ApplyVariableValues(logEntry.get_FsmVariablesCopy());
            }
            else
            {
                Debug.LogError("Missing Local Variables Cache!");
            }
            if (logEntry.get_GlobalVariablesCopy() != null)
            {
                SkillVariables.get_GlobalVariables().ApplyVariableValues(logEntry.get_GlobalVariablesCopy());
            }
            else
            {
                Debug.LogError("Missing global Variables Cache!");
            }
            if (SkillEditor.SelectedFsm == fsm)
            {
                SkillEditor.VariableManager.UpdateView();
                GlobalVariablesWindow.UpdateView();
                SkillEditor.Repaint(false);
            }
        }
예제 #16
0
        private static SkillLogEntry FindMostRecentLogEntry(SkillLog fsmLog, int fromFrame)
        {
            if (fsmLog == null || fsmLog.get_Entries() == null)
            {
                return(null);
            }
            SkillLogEntry result = null;

            using (List <SkillLogEntry> .Enumerator enumerator = fsmLog.get_Entries().GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    SkillLogEntry current = enumerator.get_Current();
                    if (current.get_LogType() == 6 || current.get_LogType() == 8 || current.get_LogType() == 7)
                    {
                        result = current;
                    }
                }
            }
            return(result);
        }
예제 #17
0
        private static SkillLogEntry FindClosestLogEntry(SkillLog fsmLog, float time)
        {
            SkillLogEntry result = null;

            using (List <SkillLogEntry> .Enumerator enumerator = fsmLog.get_Entries().GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    SkillLogEntry current = enumerator.get_Current();
                    if (current.get_Time() > time)
                    {
                        break;
                    }
                    if (current.get_LogType() == 6)
                    {
                        result = current;
                    }
                }
            }
            return(result);
        }
예제 #18
0
        private static SkillLogEntry FindNextLogEntry(SkillLogEntry fromEntry, params SkillLogType[] logTypes)
        {
            SkillLog log = fromEntry.get_Log();

            if (log == null)
            {
                return(null);
            }
            int num = DebugFlow.SelectedLog.get_Entries().IndexOf(fromEntry);

            for (int i = num + 1; i < log.get_Entries().get_Count(); i++)
            {
                SkillLogEntry fsmLogEntry = log.get_Entries().get_Item(i);
                for (int j = 0; j < logTypes.Length; j++)
                {
                    SkillLogType fsmLogType = logTypes[j];
                    if (fsmLogEntry.get_LogType() == fsmLogType)
                    {
                        return(fsmLogEntry);
                    }
                }
            }
            return(null);
        }
예제 #19
0
 public static void SetDebugTime(float time)
 {
     DebugFlow.CurrentDebugTime = time;
     using (List <Skill> .Enumerator enumerator = SkillEditor.FsmList.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             Skill current = enumerator.get_Current();
             if (current != null)
             {
                 SkillLogEntry logEntry = DebugFlow.FindClosestLogEntry(current.get_MyLog(), time);
                 if (SkillEditor.SelectedFsm == current)
                 {
                     DebugFlow.SelectLogEntry(logEntry, false);
                 }
                 else
                 {
                     DebugFlow.RestoreNearestVariables(logEntry);
                 }
             }
         }
     }
     SkillLogger.SetDebugFlowTime(time);
 }
예제 #20
0
 private void LogEntrySelected(SkillLogEntry logEntry)
 {
     this.timelineControl.FrameTime(logEntry.get_Time(), 0f);
 }
예제 #21
0
 private bool ShowHitGameObject(SkillLogEntry entry)
 {
     return(entry.get_GameObject() != null || !string.IsNullOrEmpty(entry.get_GameObjectName()));
 }
예제 #22
0
 private bool ShowEventTarget(SkillLogEntry entry)
 {
     return(entry.get_LogType() == 8 && entry.get_EventTarget().target != null);
 }
예제 #23
0
 private bool ShowSentBy(SkillLogEntry entry)
 {
     return(entry.get_LogType() == 3 && FsmEditorSettings.LogShowSentBy && entry.get_SentByState() != null && entry.get_SentByState() != entry.get_State());
 }
예제 #24
0
 private bool EntryIsVisible(SkillLogEntry entry)
 {
     return(!string.IsNullOrEmpty(entry.get_Text()) && (entry.get_LogType() != 5 || FsmEditorSettings.LogShowExit));
 }
예제 #25
0
        private void OnClickEventTarget(SkillLogEntry entry)
        {
            switch (entry.get_EventTarget().target)
            {
            case 0:
            case 6:
                break;

            case 1:
                if (entry.get_Event() != null)
                {
                    GenericMenu  genericMenu = new GenericMenu();
                    List <Skill> fsmList     = SkillInfo.GetFsmList(SkillInfo.FindTransitionsUsingEvent(entry.get_Event().get_Name()));
                    using (List <Skill> .Enumerator enumerator = fsmList.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Skill current = enumerator.get_Current();
                            genericMenu.AddItem(new GUIContent(Labels.GetFullFsmLabel(current)), false, new GenericMenu.MenuFunction2(SkillEditor.SelectFsm), current);
                        }
                    }
                    genericMenu.ShowAsContext();
                    return;
                }
                break;

            case 2:
            {
                GameObject ownerDefaultTarget = SkillEditor.SelectedFsm.GetOwnerDefaultTarget(entry.get_EventTarget().gameObject);
                Skill      fsm = SkillSelection.FindFsmOnGameObject(ownerDefaultTarget, entry.get_EventTarget().fsmName.get_Value());
                if (fsm != null)
                {
                    SkillEditor.SelectFsm(fsm);
                    return;
                }
                break;
            }

            case 3:
                if (entry.get_EventTarget().fsmComponent != null)
                {
                    SkillEditor.SelectFsm(entry.get_EventTarget().fsmComponent.get_Fsm());
                    return;
                }
                break;

            case 4:
                if (entry.get_Event() != null)
                {
                    GenericMenu  genericMenu2 = new GenericMenu();
                    List <Skill> fsmList2     = SkillInfo.GetFsmList(SkillInfo.FindTransitionsUsingEvent(entry.get_Event().get_Name()));
                    using (List <Skill> .Enumerator enumerator2 = fsmList2.GetEnumerator())
                    {
                        while (enumerator2.MoveNext())
                        {
                            Skill current2 = enumerator2.get_Current();
                            genericMenu2.AddItem(new GUIContent(Labels.GetFullFsmLabel(current2)), false, new GenericMenu.MenuFunction2(SkillEditor.SelectFsm), current2);
                        }
                    }
                    genericMenu2.ShowAsContext();
                    return;
                }
                break;

            case 5:
                SkillEditor.SelectFsm(entry.get_State().get_Fsm().get_Host());
                break;

            default:
                return;
            }
        }
예제 #26
0
        private void DoLogLine(SkillLogEntry entry, int index)
        {
            if (!this.EntryIsVisible(entry))
            {
                return;
            }
            if (entry.get_LogType() == 6)
            {
                this.currentState = entry.get_State();
                SkillEditorGUILayout.Divider(new GUILayoutOption[0]);
            }
            if (this.selectedEntry != null && index > this.selectedEntryIndex)
            {
                GUI.set_color(new Color(1f, 1f, 1f, 0.3f));
            }
            if (entry.get_LogType() == 9 || entry.get_LogType() == 10)
            {
                GUI.set_backgroundColor(SkillEditorStyles.DefaultBackgroundColor);
            }
            else
            {
                GUI.set_backgroundColor((this.currentState != null) ? PlayMakerPrefs.get_Colors()[this.currentState.get_ColorIndex()] : Color.get_grey());
            }
            GUILayout.BeginVertical(SkillEditorStyles.LogBackground, new GUILayoutOption[0]);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            Color backgroundColor = GUI.get_backgroundColor();

            GUI.set_backgroundColor(Color.get_white());
            GUIStyle gUIStyle = SkillEditorStyles.GetLogTypeStyles()[entry.get_LogType()];

            GUILayout.Label("", gUIStyle, new GUILayoutOption[]
            {
                GUILayout.MaxWidth(20f)
            });
            GUI.set_backgroundColor(backgroundColor);
            gUIStyle = SkillEditorStyles.LogLine;
            if (GUILayout.Button(FsmEditorSettings.LogShowTimecode ? entry.get_TextWithTimecode() : entry.get_Text(), gUIStyle, new GUILayoutOption[0]))
            {
                this.SelectLogEntry(entry);
            }
            GUILayout.EndHorizontal();
            if (this.ShowSentBy(entry))
            {
                if (string.IsNullOrEmpty(entry.get_Text2()))
                {
                    entry.set_Text2(Strings.get_FsmLog_Label_Sent_By() + Labels.GetFullStateLabel(entry.get_SentByState()));
                    if (entry.get_Action() != null)
                    {
                        entry.set_Text2(entry.get_Text2() + " : " + Labels.GetActionLabel(entry.get_Action()));
                    }
                }
                if (GUILayout.Button(entry.get_Text2(), SkillEditorStyles.LogLine2, new GUILayoutOption[0]))
                {
                    SkillLogger.OnClickSentBy(entry);
                }
                EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), 4);
            }
            else
            {
                if (this.ShowEventTarget(entry))
                {
                    if (string.IsNullOrEmpty(entry.get_Text2()))
                    {
                        entry.set_Text2(Strings.get_FsmLog_Label_Target() + SkillLogger.GetEventTargetLabel(entry));
                    }
                    if (GUILayout.Button(entry.get_Text2(), SkillEditorStyles.LogLine2, new GUILayoutOption[0]))
                    {
                        this.OnClickEventTarget(entry);
                        GUIUtility.ExitGUI();
                        return;
                    }
                    EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), 4);
                }
                else
                {
                    if (this.ShowHitGameObject(entry))
                    {
                        if (string.IsNullOrEmpty(entry.get_Text2()))
                        {
                            entry.set_Text2("WITH: " + entry.get_GameObjectName());
                            entry.set_GameObjectIcon(EditorHacks.GetIconForObject(entry.get_GameObject()));
                        }
                        if (entry.get_GameObject() != null)
                        {
                            if (GUILayout.Button(entry.get_Text2(), SkillEditorStyles.LogLine2, new GUILayoutOption[0]))
                            {
                                Selection.set_activeGameObject(entry.get_GameObject());
                                GUIUtility.ExitGUI();
                                return;
                            }
                            Rect lastRect = GUILayoutUtility.GetLastRect();
                            EditorGUIUtility.AddCursorRect(lastRect, 4);
                            if (entry.get_GameObjectIcon() != null)
                            {
                                lastRect.Set(lastRect.get_xMin(), lastRect.get_yMin() + 2f, 27f, lastRect.get_height() - 2f);
                                GUI.Label(lastRect, entry.get_GameObjectIcon());
                            }
                        }
                        else
                        {
                            GUILayout.Label(entry.get_Text2() + " (Destroyed)", SkillEditorStyles.LogLine2, new GUILayoutOption[0]);
                        }
                    }
                }
            }
            GUILayout.EndVertical();
            if (entry == this.selectedEntry)
            {
                this.beforeSelected = this.prevEntry;
                GUI.set_backgroundColor(Color.get_white());
                GUILayout.Box(GUIContent.none, SkillEditorStyles.LogLineTimeline, new GUILayoutOption[0]);
            }
            if (this.prevEntry == this.selectedEntry)
            {
                this.afterSelected = entry;
            }
            this.prevEntry = entry;
            this.numEntriesDrawn++;
        }