예제 #1
0
            /// <summary>
            /// Checks if a node can be adopted by this one.
            /// </summary>
            /// <param name="child">The node we want to adopt.</param>
            /// <returns>Returns true if this node can adopt the given child.</returns>
            public bool CanAdoptNode(BaseNode child)
            {
                Connector connector = GetConnector(child.ParentConnector.Identifier);

                if (connector == null)
                {
                    return(false);
                }

                return(connector != null && connector.AcceptsChild(child.GetType()));
            }
예제 #2
0
            /// <summary>
            /// Convenience method to check if all connected children are accepted.
            /// </summary>
            /// <param name="children">The children we want to adopt.</param>
            /// <returns>Returns if the connector will accept the children.</returns>
            public bool AcceptsChildren(Connector conn)
            {
                List <Type> children = new List <Type>(conn.ChildCount);

                for (int i = 0; i < conn.ChildCount; ++i)
                {
                    BaseNode node = conn.GetChild(i);

                    // if the owner itself is part of the list we ignore him
                    if (node == Owner)
                    {
                        continue;
                    }

                    children.Add(node.GetType());
                }

                return(AcceptsChildren(children));
            }