Esempio n. 1
0
        public void Replace(NodePath path, Node node, bool reconnect)
        {
            Node parent;
            int  idx;

            if (path.Count == 0)
            {
                parent = Parent;
                idx    = Parent.Children.IndexOf(this);
            }
            else
            {
                path = new NodePath(path);

                idx    = (int)path.Pop();
                parent = FromPath(path);
            }

            Node orig = parent.Children[idx];

            parent.Children[idx] = node;
            node.Parent          = parent;

            if (reconnect)
            {
                foreach (Node child in orig.Children)
                {
                    node.Add(child);
                }
            }
        }
Esempio n. 2
0
        public Node FromPath(NodePath path)
        {
            Node node = this;

            path = new NodePath(path);

            while (path.Count != 0)
            {
                uint idx = path.Pop();

                if (idx >= (uint)node.Children.Count)
                {
                    return(null);
                }

                node = node.Children[(int)idx];
            }

            return(node);
        }