void USimpleConstructionScript::RemoveNodeAndPromoteChildren(USCS_Node* Node) { Node->Modify(); if (RootNodes.Contains(Node)) { USCS_Node* ChildToPromote = nullptr; int32 PromoteIndex = FindPromotableChildNodeIndex(Node); if(PromoteIndex != INDEX_NONE) { ChildToPromote = Node->ChildNodes[PromoteIndex]; Node->ChildNodes.RemoveAt(PromoteIndex); } Modify(); if(ChildToPromote != NULL) { ChildToPromote->Modify(); RootNodes.Add(ChildToPromote); ChildToPromote->ChildNodes.Append(Node->ChildNodes); ChildToPromote->bIsParentComponentNative = Node->bIsParentComponentNative; ChildToPromote->ParentComponentOrVariableName = Node->ParentComponentOrVariableName; ChildToPromote->ParentComponentOwnerClassName = Node->ParentComponentOwnerClassName; } RootNodes.Remove(Node); Node->bIsParentComponentNative = false; Node->ParentComponentOrVariableName = NAME_None; Node->ParentComponentOwnerClassName = NAME_None; ValidateSceneRootNodes(); } // Not the root so need to promote in place of node. else { USCS_Node* ParentNode = FindParentNode(Node); checkSlow(ParentNode); ParentNode->Modify(); // remove node and move children onto parent int32 Location = ParentNode->ChildNodes.Find(Node); ParentNode->ChildNodes.Remove(Node); ParentNode->ChildNodes.Insert(Node->ChildNodes, Location); } // Clear out references to previous children Node->ChildNodes.Empty(); }
void USimpleConstructionScript::RemoveNode(USCS_Node* Node) { // If it's a root node we are removing, clear it from the list if(RootNodes.Contains(Node)) { Modify(); RootNodes.Remove(Node); Node->Modify(); Node->bIsParentComponentNative = false; Node->ParentComponentOrVariableName = NAME_None; Node->ParentComponentOwnerClassName = NAME_None; ValidateSceneRootNodes(); } // Not the root, so iterate over all nodes looking for the one with us in its ChildNodes array else { USCS_Node* ParentNode = FindParentNode(Node); if(ParentNode != NULL) { ParentNode->Modify(); ParentNode->ChildNodes.Remove(Node); } } }
void USimpleConstructionScript::RemoveNodeAndPromoteChildren(USCS_Node* Node) { Node->Modify(); if (RootNodes.Contains(Node)) { USCS_Node* ChildToPromote = nullptr; int32 PromoteIndex = FindPromotableChildNodeIndex(Node); if(PromoteIndex != INDEX_NONE) { ChildToPromote = Node->GetChildNodes()[PromoteIndex]; Node->RemoveChildNodeAt(PromoteIndex, false); } Modify(); if(ChildToPromote != NULL) { ChildToPromote->Modify(); RootNodes.Add(ChildToPromote); ChildToPromote->MoveChildNodes(Node); ChildToPromote->bIsParentComponentNative = Node->bIsParentComponentNative; ChildToPromote->ParentComponentOrVariableName = Node->ParentComponentOrVariableName; ChildToPromote->ParentComponentOwnerClassName = Node->ParentComponentOwnerClassName; } RootNodes.Remove(Node); AllNodes.Remove(Node); Node->bIsParentComponentNative = false; Node->ParentComponentOrVariableName = NAME_None; Node->ParentComponentOwnerClassName = NAME_None; ValidateSceneRootNodes(); } // Not the root so need to promote in place of node. else { USCS_Node* ParentNode = FindParentNode(Node); if (!ensure(ParentNode)) { #if WITH_EDITOR UE_LOG(LogBlueprint, Error, TEXT("RemoveNodeAndPromoteChildren(%s) failed to find a parent node in Blueprint %s, attaching children to the root"), *Node->GetName(), *GetBlueprint()->GetPathName()); #endif ParentNode = GetDefaultSceneRootNode(); } check(ParentNode); if (ParentNode != nullptr) { ParentNode->Modify(); // remove node and move children onto parent const int32 Location = ParentNode->GetChildNodes().Find(Node); ParentNode->RemoveChildNode(Node); ParentNode->MoveChildNodes(Node, Location); } } }