Example #1
0
        public bool DrawNode(Vector2 offset, bool drawSelected, bool disabled)
        {
            if (drawSelected != this.mSelected)
            {
                return(false);
            }
            if (ToString().Length != prevFriendlyNameLength)
            {
                prevFriendlyNameLength = ToString().Length;
                mRectIsDirty           = true;
            }
            Rect rect = Rectangle(offset, false, false);

            UpdateCache(rect);
            bool  flag   = (this.mTask.NodeData.PushTime != -1f && this.mTask.NodeData.PushTime >= this.mTask.NodeData.PopTime) || (this.isEntryDisplay && this.outgoingNodeConnections.Count > 0 && this.outgoingNodeConnections[0].DestinationNodeDesigner.Task.NodeData.PushTime != -1f);
            bool  flag2  = this.mIdentifyUpdateCount != -1;
            bool  result = this.prevRunningState != flag;
            float num    = (!BehaviorDesignerPreferences.GetBool(BDPreferences.FadeNodes)) ? 0.01f : 0.5f;
            float num2   = 0f;

            if (flag2)
            {
                if (2000 - this.mIdentifyUpdateCount < 500)
                {
                    num2 = (float)(2000 - this.mIdentifyUpdateCount) / 500f;
                }
                else
                {
                    num2 = 1f;
                }
                if (this.mIdentifyUpdateCount != -1)
                {
                    this.mIdentifyUpdateCount++;
                    if (this.mIdentifyUpdateCount > 2000)
                    {
                        this.mIdentifyUpdateCount = -1;
                    }
                }
                result = true;
            }
            else if (flag)
            {
                num2 = 1f;
            }
            else if ((this.mTask.NodeData.PopTime != -1f && num != 0f && Time.realtimeSinceStartup - this.mTask.NodeData.PopTime < num) || (this.isEntryDisplay && this.outgoingNodeConnections.Count > 0 && this.outgoingNodeConnections[0].DestinationNodeDesigner.Task.NodeData.PopTime != -1f && Time.realtimeSinceStartup - this.outgoingNodeConnections[0].DestinationNodeDesigner.Task.NodeData.PopTime < num))
            {
                if (this.isEntryDisplay)
                {
                    num2 = 1f - (Time.realtimeSinceStartup - this.outgoingNodeConnections[0].DestinationNodeDesigner.Task.NodeData.PopTime) / num;
                }
                else
                {
                    num2 = 1f - (Time.realtimeSinceStartup - this.mTask.NodeData.PopTime) / num;
                }
                result = true;
            }
            if (!this.isEntryDisplay && !this.prevRunningState && this.parentNodeDesigner != null)
            {
                this.parentNodeDesigner.BringConnectionToFront(this);
            }
            this.prevRunningState = flag;
            if (num2 != 1f)
            {
                GUI.color = ((!disabled && !this.mTask.NodeData.Disabled) ? Color.white : this.grayColor);
                GUIStyle backgroundGUIStyle;
                if (BehaviorDesignerPreferences.GetBool(BDPreferences.CompactMode))
                {
                    backgroundGUIStyle = ((!this.mSelected) ? BehaviorDesignerUtility.GetTaskCompactGUIStyle(this.mTask.NodeData.ColorIndex) : BehaviorDesignerUtility.GetTaskSelectedCompactGUIStyle(this.mTask.NodeData.ColorIndex));
                }
                else
                {
                    backgroundGUIStyle = ((!this.mSelected) ? BehaviorDesignerUtility.GetTaskGUIStyle(this.mTask.NodeData.ColorIndex) : BehaviorDesignerUtility.GetTaskSelectedGUIStyle(this.mTask.NodeData.ColorIndex));
                }
                this.DrawNodeTexture(rect, BehaviorDesignerUtility.GetTaskConnectionTopTexture(this.mTask.NodeData.ColorIndex), BehaviorDesignerUtility.GetTaskConnectionBottomTexture(this.mTask.NodeData.ColorIndex), backgroundGUIStyle, BehaviorDesignerUtility.GetTaskBorderTexture(this.mTask.NodeData.ColorIndex));
            }
            if (num2 > 0f)
            {
                GUIStyle  backgroundGUIStyle2;
                Texture2D iconBorderTexture;
                if (flag2)
                {
                    if (BehaviorDesignerPreferences.GetBool(BDPreferences.CompactMode))
                    {
                        if (this.mSelected)
                        {
                            backgroundGUIStyle2 = BehaviorDesignerUtility.TaskIdentifySelectedCompactGUIStyle;
                        }
                        else
                        {
                            backgroundGUIStyle2 = BehaviorDesignerUtility.TaskIdentifyCompactGUIStyle;
                        }
                    }
                    else if (this.mSelected)
                    {
                        backgroundGUIStyle2 = BehaviorDesignerUtility.TaskIdentifySelectedGUIStyle;
                    }
                    else
                    {
                        backgroundGUIStyle2 = BehaviorDesignerUtility.TaskIdentifyGUIStyle;
                    }
                    iconBorderTexture = BehaviorDesignerUtility.TaskBorderIdentifyTexture;
                }
                else
                {
                    if (BehaviorDesignerPreferences.GetBool(BDPreferences.CompactMode))
                    {
                        if (this.mSelected)
                        {
                            backgroundGUIStyle2 = BehaviorDesignerUtility.TaskRunningSelectedCompactGUIStyle;
                        }
                        else
                        {
                            backgroundGUIStyle2 = BehaviorDesignerUtility.TaskRunningCompactGUIStyle;
                        }
                    }
                    else if (this.mSelected)
                    {
                        backgroundGUIStyle2 = BehaviorDesignerUtility.TaskRunningSelectedGUIStyle;
                    }
                    else
                    {
                        backgroundGUIStyle2 = BehaviorDesignerUtility.TaskRunningGUIStyle;
                    }
                    iconBorderTexture = BehaviorDesignerUtility.TaskBorderRunningTexture;
                }
                Color color = (!disabled && !this.mTask.NodeData.Disabled) ? Color.white : this.grayColor;
                color.a   = num2;
                GUI.color = (color);
                Texture2D connectionTopTexture    = null;
                Texture2D connectionBottomTexture = null;
                if (!this.isEntryDisplay)
                {
                    if (flag2)
                    {
                        connectionTopTexture = BehaviorDesignerUtility.TaskConnectionIdentifyTopTexture;
                    }
                    else
                    {
                        connectionTopTexture = BehaviorDesignerUtility.TaskConnectionRunningTopTexture;
                    }
                }
                if (this.isParent)
                {
                    if (flag2)
                    {
                        connectionBottomTexture = BehaviorDesignerUtility.TaskConnectionIdentifyBottomTexture;
                    }
                    else
                    {
                        connectionBottomTexture = BehaviorDesignerUtility.TaskConnectionRunningBottomTexture;
                    }
                }
                this.DrawNodeTexture(rect, connectionTopTexture, connectionBottomTexture, backgroundGUIStyle2, iconBorderTexture);
                GUI.color = (Color.white);
            }
            if (this.mTask.NodeData.Collapsed)
            {
                GUI.DrawTexture(this.nodeCollapsedTextureRect, BehaviorDesignerUtility.TaskConnectionCollapsedTexture);
            }
            if (!BehaviorDesignerPreferences.GetBool(BDPreferences.CompactMode))
            {
                GUI.DrawTexture(iconTextureRect, mTask.NodeData.Icon);
            }
            if (this.mTask.NodeData.InterruptTime != -1f && Time.realtimeSinceStartup - this.mTask.NodeData.InterruptTime < 0.75f + num)
            {
                float a;
                if (Time.realtimeSinceStartup - this.mTask.NodeData.InterruptTime < 0.75f)
                {
                    a = 1f;
                }
                else
                {
                    a = 1f - (Time.realtimeSinceStartup - (this.mTask.NodeData.InterruptTime + 0.75f)) / num;
                }
                Color white = Color.white;
                white.a   = a;
                GUI.color = (white);
                GUI.Label(rect, string.Empty, BehaviorDesignerUtility.TaskHighlightGUIStyle);
                GUI.color = (Color.white);
            }
            GUI.Label(this.titleRect, this.ToString(), BehaviorDesignerUtility.TaskTitleGUIStyle);
            if (this.mTask.NodeData.IsBreakpoint)
            {
                GUI.DrawTexture(this.breakpointTextureRect, BehaviorDesignerUtility.BreakpointTexture);
            }
            if (this.showReferenceIcon)
            {
                GUI.DrawTexture(this.referenceTextureRect, BehaviorDesignerUtility.ReferencedTexture);
            }
            if (this.hasError)
            {
                GUI.DrawTexture(this.errorTextureRect, BehaviorDesignerUtility.ErrorIconTexture);
            }
            if (this.mTask is Composite && (this.mTask as Composite).AbortType != AbortType.None)
            {
                switch ((this.mTask as Composite).AbortType)
                {
                case AbortType.Self:
                    GUI.DrawTexture(this.conditionalAbortTextureRect, BehaviorDesignerUtility.ConditionalAbortSelfTexture);
                    break;

                case AbortType.LowerPriority:
                    GUI.DrawTexture(this.conditionalAbortLowerPriorityTextureRect, BehaviorDesignerUtility.ConditionalAbortLowerPriorityTexture);
                    break;

                case AbortType.Both:
                    GUI.DrawTexture(this.conditionalAbortTextureRect, BehaviorDesignerUtility.ConditionalAbortBothTexture);
                    break;
                }
            }
            GUI.color = (Color.white);
            if (this.showHoverBar)
            {
                GUI.DrawTexture(this.disabledButtonTextureRect, (!this.mTask.NodeData.Disabled) ? BehaviorDesignerUtility.DisableTaskTexture : BehaviorDesignerUtility.EnableTaskTexture, (ScaleMode)2);
                if (this.isParent || this.mTask is BehaviorReference)
                {
                    bool collapsed = this.mTask.NodeData.Collapsed;
                    if (this.mTask is BehaviorReference)
                    {
                        collapsed = (this.mTask as BehaviorReference).collapsed;
                    }
                    GUI.DrawTexture(this.collapseButtonTextureRect, (!collapsed) ? BehaviorDesignerUtility.CollapseTaskTexture : BehaviorDesignerUtility.ExpandTaskTexture, (ScaleMode)2);
                }
            }
            return(result);
        }