/// <summary> /// Adds nodes to the referenced behaviour which represent sub-referenced behaviours. /// </summary> /// <param name="processedBehaviors">A list of processed behaviours to handle circular references.</param> /// <param name="parent">The node the sub-referenced behaviours will be added to.</param> /// <param name="node">The current node we are checking.</param> protected void GenerateReferencedBehaviorsTree(ProcessedBehaviors processedBehaviors, NodeViewData parent, Node node) { if (!processedBehaviors.MayProcess(node)) { return; } // check if this is a referenced behaviour if (node is ReferencedBehaviorNode) { // create the dummy node and add it without marking the behaviour as being modified as these are no REAL nodes. NodeViewData rb = node.CreateNodeViewData(parent, _rootBehavior); #if DEBUG rb.IsSubreferencedGraphNode(); #endif rb.DoSynchronizeWithNode(processedBehaviors); Connector conn = parent.GetConnector(Connector.kGeneric); Debug.Check(conn != null); Connector rbconn = parent.GetConnector(Connector.kGeneric); Debug.Check(rbconn != null); bool parentReadOnly = conn.IsReadOnly; conn.IsReadOnly = false; parent.AddChildNotModified(conn, rb); conn.IsReadOnly = parentReadOnly; // we have a circular reference here. Skip the children if (((ReferencedBehaviorNode)node).Reference == _rootBehavior) { rbconn.IsReadOnly = true; return; } // do the same for all the children foreach(Node child in node.Children) GenerateReferencedBehaviorsTree(processedBehaviors.Branch(child), rb, child); rbconn.IsReadOnly = true; } else if (node is Impulse) { // create the dummy node and add it without marking the behaviour as being modified as these are no REAL nodes. NodeViewData ip = node.CreateNodeViewData(parent, _rootBehavior); ip.DoSynchronizeWithNode(processedBehaviors); // do the same for all the children foreach(Node child in node.Children) GenerateReferencedBehaviorsTree(processedBehaviors.Branch(child), ip, child); if (ip.Children.Count > 0) { Connector conn = parent.GetConnector(Connector.kGeneric); Debug.Check(conn != null); Connector ipconn = ip.GetConnector(Connector.kGeneric); Debug.Check(ipconn != null); parent.AddChildNotModified(conn, ip); ipconn.IsReadOnly = true; } } else { // do the same for all the children foreach(Node child in node.Children) GenerateReferencedBehaviorsTree(processedBehaviors.Branch(child), parent, child); } }