lab.AiTree.ConnectNodes C# (CSharp) Method

ConnectNodes() public method

Creates connection between one node to another. The connection is one one-way and tries to prevent circular to prevent infinity loops.
public ConnectNodes ( AFlowNode from, ANode to ) : bool
from AFlowNode A node that is higher in hierarchy.
to ANode A node that is lower in hierarchy.
return bool
        public bool ConnectNodes(AFlowNode from, ANode to)
        {
            if (_nodes.Contains(from) && _nodes.Contains(to) && to != Root) {
                var n = to as AFlowNode;
                if (n != null) {
                    //check nodes recursive to prevent circular trees
                    if (IsConnected(from, n)) {
                        return false;
                    }
                }
                return from.AddNode(to);
            }
            return false;
        }