void UK2Node_GetArrayItem::NotifyPinConnectionListChanged(UEdGraphPin* Pin) { Super::NotifyPinConnectionListChanged(Pin); if (Pin != GetIndexPin() && Pin->ParentPin == nullptr) { UEdGraphPin* ArrayPin = Pins[0]; UEdGraphPin* ResultPin = Pins[2]; auto ClearWildcardType = [ArrayPin, ResultPin]() { ArrayPin->PinType.PinCategory = UEdGraphSchema_K2::PC_Wildcard; ArrayPin->PinType.PinSubCategory = TEXT(""); ArrayPin->PinType.PinSubCategoryObject = NULL; ResultPin->PinType.PinCategory = UEdGraphSchema_K2::PC_Wildcard; ResultPin->PinType.PinSubCategory = TEXT(""); ResultPin->PinType.PinSubCategoryObject = NULL; ResultPin->PinType.bIsReference = true; ArrayPin->BreakAllPinLinks(); ResultPin->BreakAllPinLinks(); }; const int32 NewLinkCount = Pin->LinkedTo.Num(); const bool bPinsHasLinks = (NewLinkCount > 0); if (ArrayPin == Pin) { if (bPinsHasLinks) { // if we had more than one input, we'd have to find the common base type ensure(NewLinkCount == 1); // the input array has authority, change output types, even if they are connected PropagatePinType(Pin->LinkedTo[0]->PinType); } // if the array pin was disconnected from everything, and... else if (ResultPin->LinkedTo.Num() == 0) { ClearWildcardType(); } } else if (ArrayPin->LinkedTo.Num() == 0) { // if we cleared the result pin's connections if (!bPinsHasLinks) { ClearWildcardType(); } // if this is the first connection to the result pin... else if (NewLinkCount == 1) { PropagatePinType(Pin->LinkedTo[0]->PinType); } // else, the result pin already had a connection and a type, leave // it alone, as it is what facilitated this connection as well } // else, leave this node alone, the array input is still connected and // it has authority over the wildcard types (the type set should already be good) } }
void UK2Node_MakeArray::PostReconstructNode() { // Find a pin that has connections to use to jumpstart the wildcard process for (int32 PinIndex = 0; PinIndex < Pins.Num(); ++PinIndex) { if (Pins[PinIndex]->LinkedTo.Num() > 0) { // The pin is linked, continue to use its type as the type for all pins. // Update the types on all the pins UEdGraphPin* OutputPin = GetOutputPin(); OutputPin->PinType = Pins[PinIndex]->LinkedTo[0]->PinType; OutputPin->PinType.bIsArray = true; PropagatePinType(); break; } else if(!Pins[PinIndex]->GetDefaultAsString().IsEmpty()) { // The pin has user data in it, continue to use its type as the type for all pins. // Update the types on all the pins UEdGraphPin* OutputPin = GetOutputPin(); OutputPin->PinType = Pins[PinIndex]->PinType; OutputPin->PinType.bIsArray = true; PropagatePinType(); break; } } }
void UK2Node_MakeArray::NotifyPinConnectionListChanged(UEdGraphPin* Pin) { Super::NotifyPinConnectionListChanged(Pin); const UEdGraphSchema_K2* Schema = GetDefault<UEdGraphSchema_K2>(); // Was this the first or last connection? int32 NumPinsWithLinks = 0; // Array to cache the input pins we might want to find these if we are removing the last link TArray< UEdGraphPin* > InputPins; for (int32 PinIndex = 0; PinIndex < Pins.Num(); ++PinIndex) { NumPinsWithLinks += (Pins[PinIndex]->LinkedTo.Num() > 0) ? 1 : 0; if( Pins[PinIndex]->Direction == EGPD_Input ) { InputPins.Add(Pins[PinIndex]); } } UEdGraphPin* OutputPin = GetOutputPin(); if (Pin->LinkedTo.Num() > 0) { // Just made a connection, was it the first? if (NumPinsWithLinks == 1) { // Update the types on all the pins OutputPin->PinType = Pin->LinkedTo[0]->PinType; OutputPin->PinType.bIsArray = true; PropagatePinType(); } } else { // Just broke a connection, was it the last? if (NumPinsWithLinks == 0) { // Return to wildcard if theres nothing in any of the input pins bool bResetOutputPin = true; for (int32 PinIndex = 0; PinIndex < InputPins.Num(); ++PinIndex) { if( InputPins[PinIndex]->GetDefaultAsString().IsEmpty() == false ) { bResetOutputPin = false; } } if( bResetOutputPin == true ) { OutputPin->PinType.PinCategory = Schema->PC_Wildcard; OutputPin->PinType.PinSubCategory = TEXT(""); OutputPin->PinType.PinSubCategoryObject = NULL; PropagatePinType(); } } } }
void UK2Node_GetArrayItem::PostReconstructNode() { if (GetTargetArrayPin()->LinkedTo.Num() > 0) { PropagatePinType(GetTargetArrayPin()->LinkedTo[0]->PinType); } else if (GetResultPin()->LinkedTo.Num() > 0) { PropagatePinType(GetResultPin()->LinkedTo[0]->PinType); } }
void UK2Node_MakeArray::ClearPinTypeToWildcard() { bool bClearPinsToWildcard = true; // Check to see if we want to clear the wildcards. for (int32 PinIndex = 0; PinIndex < Pins.Num(); ++PinIndex) { if(Pins[PinIndex]->LinkedTo.Num() > 0) { // One of the pins is still linked, we will not be clearing the types. bClearPinsToWildcard = false; break; } else if( Pins[PinIndex]->Direction == EGPD_Input ) { if( Pins[PinIndex]->GetDefaultAsString().IsEmpty() == false ) { // One of the pins has data the user may not want to have cleared, we will not be clearing the types. bClearPinsToWildcard = false; break; } } } if( bClearPinsToWildcard == true ) { const UEdGraphSchema_K2* Schema = GetDefault<UEdGraphSchema_K2>(); UEdGraphPin* OutputPin = GetOutputPin(); OutputPin->PinType.PinCategory = Schema->PC_Wildcard; OutputPin->PinType.PinSubCategory = TEXT(""); OutputPin->PinType.PinSubCategoryObject = NULL; PropagatePinType(); } }