MCPcopy Create free account
hub / github.com/MothCocoon/FlowGraph / HarvestNodeConnections

Method HarvestNodeConnections

Source/Flow/Private/FlowAsset.cpp:514–614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

512}
513
514void UFlowAsset::HarvestNodeConnections(UFlowNode* TargetNode)
515{
516 TArray<UFlowNode*> TargetNodes;
517
518 if (IsValid(TargetNode))
519 {
520 TargetNodes.Reserve(1);
521 TargetNodes.Add(TargetNode);
522 }
523 else
524 {
525 TargetNodes.Reserve(Nodes.Num());
526 for (const TPair<FGuid, UFlowNode*>& Pair : ObjectPtrDecay(Nodes))
527 {
528 TargetNodes.Add(Pair.Value);
529 }
530 }
531
532 // Remove any invalid nodes
533 for (auto NodeIt = TargetNodes.CreateIterator(); NodeIt; ++NodeIt)
534 {
535 if (*NodeIt == nullptr)
536 {
537 NodeIt.RemoveCurrent();
538 Modify();
539 }
540 }
541
542 for (UFlowNode* FlowNode : TargetNodes)
543 {
544 bool bNodeDirty = false;
545
546 TMap<FName, FConnectedPin> FoundConnections;
547 const TArray<UEdGraphPin*>& GraphNodePins = FlowNode->GetGraphNode()->Pins;
548
549 for (const UEdGraphPin* ThisPin : GraphNodePins)
550 {
551 const bool bIsExecPin = FFlowPin::IsExecPinCategory(ThisPin->PinType.PinCategory);
552 const bool bIsDataPin = !bIsExecPin;
553 const bool bIsOutputPin = (ThisPin->Direction == EGPD_Output);
554 const bool bIsInputPin = (ThisPin->Direction == EGPD_Input);
555 const bool bHasAtLeastOneConnection = ThisPin->LinkedTo.Num() > 0;
556
557 if (bIsExecPin && bIsOutputPin && bHasAtLeastOneConnection)
558 {
559 // For Exec Pins, harvest the 0th connection (we should have only 1 connection, because of schema rules)
560 if (const UEdGraphPin* LinkedPin = ThisPin->LinkedTo[0])
561 {
562 const UEdGraphNode* LinkedNode = LinkedPin->GetOwningNode();
563 FoundConnections.Add(ThisPin->PinName, FConnectedPin(LinkedNode->NodeGuid, LinkedPin->PinName));
564 }
565 }
566 else if (bIsDataPin && bIsInputPin && bHasAtLeastOneConnection)
567 {
568 // For Data Pins, harvest the 0th connection (we should have only 1 connection, because of schema rules)
569 if (const UEdGraphPin* LinkedPin = ThisPin->LinkedTo[0])
570 {
571 const UEdGraphNode* LinkedNode = LinkedPin->GetOwningNode();

Callers 4

NotifyGraphChangedMethod · 0.80
CreateFlowInstanceMethod · 0.80

Calls 3

IsValidFunction · 0.85
FConnectedPinFunction · 0.85
SetConnectionsMethod · 0.80

Tested by

no test coverage detected