public static SqfNode GetParent(this SqfNode node) { SqfNode weak; if (node.ParentWeak.TryGetTarget(out weak)) { return(weak); } return(default(SqfNode)); }
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); } }
public static int ParentCount(this SqfNode node) { int i = 0; var tmp = node; while ((tmp = tmp.GetParent()) != null) { i++; } return(i); }
public static void AddChild(this SqfNode node, SqfNode newChild) { node.Children.Add(newChild); }
public static void SetParent(this SqfNode node, SqfNode parent) { node.ParentWeak.SetTarget(parent); }
public SqfNode(SqfNode parent) { this.ParentWeak = new WeakReference <SqfNode>(parent); this.Children = new List <SqfNode>(); }
public SqfAssignment(SqfNode parent) : base(parent) { }