Example #1
0
        public static SqfNode GetParent(this SqfNode node)
        {
            SqfNode weak;

            if (node.ParentWeak.TryGetTarget(out weak))
            {
                return(weak);
            }
            return(default(SqfNode));
        }
Example #2
0
        public static void RemoveFromTree(this SqfNode node)
        {
            var parent    = node.GetParent();
            var nodeIndex = parent.Children.IndexOf(node);

            parent.Children.Remove(node);
            foreach (var it in node.Children)
            {
                parent.Children.Insert(nodeIndex, it);
            }
        }
Example #3
0
        public static int ParentCount(this SqfNode node)
        {
            int i   = 0;
            var tmp = node;

            while ((tmp = tmp.GetParent()) != null)
            {
                i++;
            }
            return(i);
        }
Example #4
0
 public static void AddChild(this SqfNode node, SqfNode newChild)
 {
     node.Children.Add(newChild);
 }
Example #5
0
 public static void SetParent(this SqfNode node, SqfNode parent)
 {
     node.ParentWeak.SetTarget(parent);
 }
Example #6
0
 public SqfNode(SqfNode parent)
 {
     this.ParentWeak = new WeakReference <SqfNode>(parent);
     this.Children   = new List <SqfNode>();
 }
Example #7
0
 public SqfAssignment(SqfNode parent) : base(parent)
 {
 }