Example #1
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);
     }
 }
        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);
            }
        }
        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();
        }
 private bool ShowSentBy(SkillLogEntry entry)
 {
     return(entry.get_LogType() == 3 && FsmEditorSettings.LogShowSentBy && entry.get_SentByState() != null && entry.get_SentByState() != entry.get_State());
 }
        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;
            }
        }
        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++;
        }