Ejemplo n.º 1
0
        /// <summary>
        /// Removes node from tree.
        /// <param name="node">The node to be removed.</param>
        /// <param name="includeHierarchy">If true, the hierarchy will also be removed.</param>
        /// </summary>
        public void RemoveNode(ActionNode node, bool includeHierarchy)
        {
            GetNodes();
            var        nodes  = new List <ActionNode>(m_Nodes);
            BranchNode branch = node as BranchNode;

            // Remove children
            if (includeHierarchy && branch != null)
            {
                foreach (ActionNode n in branch.GetHierarchy())
                {
                    nodes.Remove(n);
                }
            }

            // Remove node
            nodes.Remove(node);
            m_Nodes = nodes.ToArray();

            if (Application.isPlaying && this.enabled)
            {
                // Update function nodes
                m_FunctionNodes = this.GetFunctionNodes();
                // Reset status
                node.ResetStatus();
                // Disable node
                node.OnDisable();
            }

            HierarchyChanged();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the nodes order.
        /// </summary>
        void UpdateNodes()
        {
            var oldNodes = GetNodes();

            // Get all root nodes
            var rootNodes = new List <ActionNode>();

            foreach (ActionNode n in oldNodes)
            {
                if (n.isRoot)
                {
                    rootNodes.Add(n);
                }
            }

            var newNodes = new List <ActionNode>();

            for (int i = 0; i < rootNodes.Count; i++)
            {
                BranchNode branch = rootNodes[i] as BranchNode;
                if (branch != null)
                {
                    newNodes.AddRange(branch.GetHierarchy());
                }
                else
                {
                    newNodes.Add(rootNodes[i]);
                }
            }
            m_Nodes = newNodes.ToArray();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns the branch hierarchy nodes.
        /// <returns>Tha branch node and all children/subchildren.<returns>
        /// </summary>
        public ActionNode[] GetHierarchy()
        {
            List <ActionNode> allNodes = new List <ActionNode>()
            {
                this
            };

            {
                var __array1       = this.children;
                var __arrayLength1 = __array1.Length;
                for (int __i1 = 0; __i1 < __arrayLength1; ++__i1)
                {
                    var child = (ActionNode)__array1[__i1];
                    {
                        BranchNode childBranch = child as BranchNode;
                        if (childBranch != null)
                        {
                            allNodes.AddRange(childBranch.GetHierarchy());
                        }
                        else
                        {
                            allNodes.Add(child);
                        }
                    }
                }
            }
            return(allNodes.ToArray());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns the branch hierarchy nodes.
        /// <returns>Tha branch node and all children/subchildren.<returns>
        /// </summary>
        public ActionNode[] GetHierarchy()
        {
            List <ActionNode> allNodes = new List <ActionNode>()
            {
                this
            };

            foreach (ActionNode child in this.children)
            {
                BranchNode childBranch = child as BranchNode;
                if (childBranch != null)
                {
                    allNodes.AddRange(childBranch.GetHierarchy());
                }
                else
                {
                    allNodes.Add(child);
                }
            }

            return(allNodes.ToArray());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Removes node from tree.
        /// <param name="node">The node to be removed.</param>
        /// <param name="includeHierarchy">If true, the hierarchy will also be removed.</param>
        /// </summary>
        public void RemoveNode(ActionNode node, bool includeHierarchy)
        {
            GetNodes();
            var        nodes  = new List <ActionNode>(m_Nodes);
            BranchNode branch = node as BranchNode;

            // Remove children
            if (includeHierarchy && branch != null)
            {
                {
                    var __array3       = branch.GetHierarchy();
                    var __arrayLength3 = __array3.Length;
                    for (int __i3 = 0; __i3 < __arrayLength3; ++__i3)
                    {
                        var n = (ActionNode)__array3[__i3];
                        {
                            nodes.Remove(n);
                        }
                    }
                }
            }

            // Remove node
            nodes.Remove(node);
            m_Nodes = nodes.ToArray();

            if (Application.isPlaying && this.enabled)
            {
                // Update function nodes
                m_FunctionNodes = this.GetFunctionNodes();
                // Reset status
                node.ResetStatus();
                // Disable node
                node.OnDisable();
            }

            HierarchyChanged();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Updates the nodes order.
        /// </summary>
        void UpdateNodes()
        {
            var oldNodes = GetNodes();

            // Get all root nodes
            var rootNodes = new List <ActionNode>();
            {
                // foreach(var n in oldNodes)
                var __enumerator1 = (oldNodes).GetEnumerator();
                while (__enumerator1.MoveNext())
                {
                    var n = (ActionNode)__enumerator1.Current;
                    {
                        if (n.isRoot)
                        {
                            rootNodes.Add(n);
                        }
                    }
                }
            }

            var newNodes = new List <ActionNode>();

            for (int i = 0; i < rootNodes.Count; i++)
            {
                BranchNode branch = rootNodes[i] as BranchNode;
                if (branch != null)
                {
                    newNodes.AddRange(branch.GetHierarchy());
                }
                else
                {
                    newNodes.Add(rootNodes[i]);
                }
            }
            m_Nodes = newNodes.ToArray();
        }