Files
UnrealEngineUWP/Engine/Source/Editor/BlueprintGraph/Private/K2Node_BaseAsyncTask.cpp
Robert Manuszewski aa11e3bbbf Merging UE4-Pretest @ 2042161 to UE4
Change 1996384 by Andrew Brown:
	322252 - EDITOR: Asset picker displays incorrect text when there are no filter results.
Change 1996385 by Andrew Brown:
	321858 - CRASH: Assertion failed: (Index >= 0) Function: STransformViewportToolBar::GetLocationGridLabel() STextBlock::CacheDesiredSize()
Change 1996977 by Andrew Brown:
	309685 - UE4: Adding an event/renaming an event on an event track in Matinee does not update the MatineeActor node in blueprint
Change 2034873 by Jaroslaw Palczynski:
	More robust VS installation detection.
Change 2039693 by Jaroslaw Palczynski:
	327268 - RocketGDC: POSTLAUNCH: DEV: Make engine more robust against bad Visual Studio environment variables
Change 1978978 by Jaroslaw Surowiec:
	- Removed obsolete AllowEliminatingReferences from the FArchive
Change 2020326 by Maciej Mroz:
	pretest BP K2Node: RemovePinsFromOldPins function moved from K2Node to RemovePinsFromOldPins
Change 2017608 by Maciej Mroz:
	pretest Some changes in SFortMissionEventSelector caused by FPinTypeTreeInfo
Change 2017463 by Maciej Mroz:
	PinTypeSelector can lins unloaded UDStructs
Change 2019979 by Maciej Mroz:
	pretest BP: Crash when performing Diff against Depot with blueprints containing Format Text nodes
Change 2024469 by Maciej Mroz:
	MemberReference variable added to PinType. It's necessary for delegate's signature.
Change 2024049 by Maciej Mroz:
	HasExternalBlueprintDependencies added to UK2Node_DynamicCast
Change 2024586 by Maciej Mroz:
	FillSimpleMemberReference fix
Change 2024472 by Maciej Mroz:
	workaround for delegates signature in pintype removed.
Change 2023997 by Maciej Mroz:
	BP, UDStruc: Class UserDefinedStructEditorData added. It fixes many problems with undo/redo.
Change 2021934 by Maciej Mroz:
	typo in a comment
Change 2020355 by Maciej Mroz:
	Back out changelist 2020342
Change 2022178 by Maciej Mroz:
	CRASH: PRETEST: EDITOR: UDS: Crash when undo then redo new variable in struct that is used by blueprint
Change 2021958 by Maciej Mroz:
	CRASH: PRETEST: EDITOR: UDS: Crash using variable of a type of copied struct in blueprint
Change 1986247 by Maciej Mroz:
	User Defined Structures: circle dependency fixed. Early version.
Change 1985107 by Maciej Mroz:
	UserDefinedStruct cannot have a field of a non-native type
Change 1986278 by Maciej Mroz:
	pretest ensureMsgf in Struct::link
Change 1986250 by Maciej Mroz:
	User Defined Struct: Non native classes are accepted types od values in structures.
Change 1980955 by Maciej Mroz:
	Using AssetPtr and LazyPtr as UFunction parameter (intput or return) is explicitly disallowed.
Change 2041215 by Maciej Mroz:
	ttp331249 BLOCKER: PRETEST: UI: Survive the Storm is missing the Mission HUD.
Change 1984316 by Maciej Mroz:
	New User Defined Structure. WIP - there are still problems with circular dependencies.
Change 2011616 by Maciej Mroz:
	UserDefinedStructures - various problems fixed.
Change 2011609 by Maciej Mroz:
	more robust HasExternalBlueprintDependencies implementation
Change 2016697 by Maciej Mroz:
	pretest BP: UDStruct - default value propagation in cooked build
Change 2016288 by Maciej Mroz:
	pretest BP: UDStruct: Renaming variables wont break links from make/break nodes
Change 1987637 by Maciej Mroz:
	CustomStruct icons placeholders
Change 1987422 by Maciej Mroz:
	Better tooltips for variables in MyBlueprint
Change 1991387 by Maciej Mroz:
	UDStructures fixes:
Change 2029165 by Maciej Mroz:
	BP: better comment for incomatible pins
Change 2030016 by Maciej Mroz:
	8PRETEST: EDITOR: UDS: Defaults values aren't updated in struct type variables in blueprints
Change 2030017 by Maciej Mroz:
	Unused UDStructure code removed (PPF_UseDefaultsForUDStructures)
Change 2028856 by Maciej Mroz:
	BP: Pins with PC_Struct type are compatible only with exactly the same structure. (No derived structures are not handled as compatible).
Change 2026701 by Maciej Mroz:
	k2: odd error on an add item node within a function (see attached image in details)
Change 2028160 by Maciej Mroz:
	PRETEST: EDITOR: UDS: When deleting structures just after creating there is always some references in the memory
Change 2028165 by Maciej Mroz:
	BP: BreakHitResult function has proper icon.
Change 2033340 by Maciej Mroz:
	ttp330786 PRETEST: EDITOR: UDS: Changes of default values aren't apllied to breeak nodes for text type of variables
Change 2034255 by Maciej Mroz:
	EDITOR: UDS: Changes of default values aren't apllied to make nodes for text type of variables ttp#330620
Change 2037682 by Maciej Mroz:
	ttp331309 BLOCKER: PRETEST: CRASH: EDITOR: Crash occurs when performing Diff Against Depot on any Blueprint
Change 2033142 by Maciej Mroz:
	CreateDelegate Node uses internally FMemberReference. Refactor.
Change 2032329 by Maciej Mroz:
	ttp330608 CRASH: PRETEST: EDITOR: UDS: Crash when trying to use struct named 'Color' in blueprint
Change 2032420 by Maciej Mroz:
	ttp330620 PRETEST: EDITOR: UDS: Changes of default values aren't apllied to make nodes for text type of variables
Change 2033139 by Maciej Mroz:
	Functions generated from CustomEvents can be also identified by GUID
Change 2026631 by Maciej Mroz:
	BP. UDStruct: Invalid structs are handled better.
Change 2025344 by Maciej Mroz:
	UDStruct enabled by default
Change 2026672 by Maciej Mroz:
	EDITOR: BP: Can't easily remove 'pass-by-reference' pins on ReturnNodes
Change 2026411 by Maciej Mroz:
	ExposeOnSpawn updated, it supports UDStructs, custom native Structs, and it throws compiler error.
Change 2025342 by Maciej Mroz:
	GenerateBlueprintSkeleton moved from BLueprint::Serialize to RegenerateBlueprintClass, because SkeletonClass compilation requires all external dependencies to be loaded and linked.
Change 2025570 by Steve Robb:
	Moved dependency processing to its own function.
Change 2033235 by Steve Robb:
	String improvements
Change 2035830 by Steve Robb:
	Workaround for FriendsAndChat crash in Fortnite.
Change 2035115 by Steve Robb:
	UBT build time regression fixes.
Change 2034162 by Steve Robb:
	312775: UObject improvement: Ensure that *.generated.inl is included somewhere
Change 2034181 by Steve Robb:
	Removal of any references to .generated.inl
Change 2020165 by Steve Robb:
	BuildPublicAndPrivateUObjectHeaders factored out into its own function.
Change 2020187 by Steve Robb:
	CreateModuleCompileEnvironment function factored out.
Change 2020055 by Steve Robb:
	Refactoring of Unity.cs to remove complex and duplicate iteration.
Change 2020083 by Steve Robb:
	Another use of dictionary utilities.
Change 2031049 by Steve Robb:
	312775: UObject improvement: Ensure that *.generated.inl is included somewhere
Change 2025728 by Steve Robb:
	Refactored the application of a shared PCH file to multiple file into a single ApplySharedPCH function.
Change 2020068 by Steve Robb:
	A couple of helpful utility functions for populating dictionaries.
Change 2032307 by Steve Robb:
	312775: UObject improvement: Ensure that *.generated.inl is included somewhere

[CL 2054495 by Robert Manuszewski in Main branch]
2014-04-23 20:18:55 -04:00

402 lines
17 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#include "BlueprintGraphPrivatePCH.h"
#include "CompilerResultsLog.h"
#include "KismetCompiler.h"
#include "K2ActionMenuBuilder.h"
#define LOCTEXT_NAMESPACE "UK2Node_BaseAsyncTask"
UK2Node_BaseAsyncTask::UK2Node_BaseAsyncTask(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
, ProxyFactoryFunctionName(NAME_None)
, ProxyFactoryClass(NULL)
, ProxyClass(NULL)
, ProxyActivateFunctionName(NAME_None)
{
}
FString UK2Node_BaseAsyncTask::GetTooltip() const
{
const FString FunctionToolTipText = UK2Node_CallFunction::GetDefaultTooltipForFunction(GetFactoryFunction());
return FunctionToolTipText;
}
FText UK2Node_BaseAsyncTask::GetNodeTitle(ENodeTitleType::Type TitleType) const
{
const FString FunctionToolTipText = UK2Node_CallFunction::GetUserFacingFunctionName(GetFactoryFunction());
return FText::FromString(FunctionToolTipText);
}
FString UK2Node_BaseAsyncTask::GetCategoryName()
{
const FString GenericFunctionCategory = LOCTEXT("FunctionCategory", "Call Function").ToString();
return UK2Node_CallFunction::GetDefaultCategoryForFunction(GetFactoryFunction(), GenericFunctionCategory);
}
void UK2Node_BaseAsyncTask::GetMenuEntries(FGraphContextMenuBuilder& ContextMenuBuilder) const
{
const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();
const bool bAllowLatentFuncs = (K2Schema->GetGraphType(ContextMenuBuilder.CurrentGraph) == GT_Ubergraph);
if (bAllowLatentFuncs)
{
UK2Node_BaseAsyncTask* NodeTemplate = NewObject<UK2Node_BaseAsyncTask>(ContextMenuBuilder.OwnerOfTemporaries, GetClass());
CreateDefaultMenuEntry(NodeTemplate, ContextMenuBuilder);
}
}
TSharedPtr<FEdGraphSchemaAction_K2NewNode> UK2Node_BaseAsyncTask::CreateDefaultMenuEntry(UK2Node_BaseAsyncTask* NodeTemplate, FGraphContextMenuBuilder& ContextMenuBuilder) const
{
TSharedPtr<FEdGraphSchemaAction_K2NewNode> NodeAction = FK2ActionMenuBuilder::AddNewNodeAction(ContextMenuBuilder, NodeTemplate->GetCategoryName(), NodeTemplate->GetNodeTitle(ENodeTitleType::ListView), NodeTemplate->GetTooltip(), 0, NodeTemplate->GetKeywords());
NodeAction->NodeTemplate = NodeTemplate;
NodeAction->SearchTitle = NodeTemplate->GetNodeSearchTitle();
return NodeAction;
}
void UK2Node_BaseAsyncTask::AllocateDefaultPins()
{
const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();
CreatePin(EGPD_Input, K2Schema->PC_Exec, TEXT(""), NULL, false, false, K2Schema->PN_Execute);
CreatePin(EGPD_Output, K2Schema->PC_Exec, TEXT(""), NULL, false, false, K2Schema->PN_Then);
UFunction* DelegateSignatureFunction = NULL;
for (TFieldIterator<UProperty> PropertyIt(ProxyClass, EFieldIteratorFlags::ExcludeSuper); PropertyIt; ++PropertyIt)
{
if (UMulticastDelegateProperty* Property = Cast<UMulticastDelegateProperty>(*PropertyIt))
{
CreatePin(EGPD_Output, K2Schema->PC_Exec, TEXT(""), NULL, false, false, *Property->GetName());
if (!DelegateSignatureFunction)
{
DelegateSignatureFunction = Property->SignatureFunction;
}
}
}
if (DelegateSignatureFunction)
{
for (TFieldIterator<UProperty> PropIt(DelegateSignatureFunction); PropIt && (PropIt->PropertyFlags & CPF_Parm); ++PropIt)
{
UProperty* Param = *PropIt;
const bool bIsFunctionInput = !Param->HasAnyPropertyFlags(CPF_OutParm) || Param->HasAnyPropertyFlags(CPF_ReferenceParm);
if (bIsFunctionInput)
{
UEdGraphPin* Pin = CreatePin(EGPD_Output, TEXT(""), TEXT(""), NULL, false, false, Param->GetName());
K2Schema->ConvertPropertyToPinType(Param, /*out*/ Pin->PinType);
}
}
}
bool bAllPinsGood = true;
UFunction* Function = ProxyFactoryClass->FindFunctionByName(ProxyFactoryFunctionName);
if (Function)
{
TSet<FString> PinsToHide;
FBlueprintEditorUtils::GetHiddenPinsForFunction(GetBlueprint(), Function, PinsToHide);
for (TFieldIterator<UProperty> PropIt(Function); PropIt && (PropIt->PropertyFlags & CPF_Parm); ++PropIt)
{
UProperty* Param = *PropIt;
const bool bIsFunctionInput = !Param->HasAnyPropertyFlags(CPF_OutParm) || Param->HasAnyPropertyFlags(CPF_ReferenceParm);
if (!bIsFunctionInput)
{
// skip function output, it's internal node data
continue;
}
const bool bIsRefParam = Param->HasAnyPropertyFlags(CPF_ReferenceParm) && bIsFunctionInput;
UEdGraphPin* Pin = CreatePin(EGPD_Input, TEXT(""), TEXT(""), NULL, false, bIsRefParam, Param->GetName());
const bool bPinGood = (Pin != NULL) && K2Schema->ConvertPropertyToPinType(Param, /*out*/ Pin->PinType);
if (bPinGood)
{
//Flag pin as read only for const reference property
Pin->bDefaultValueIsIgnored = Param->HasAnyPropertyFlags(CPF_ConstParm | CPF_ReferenceParm) && (!Function->HasMetaData(FBlueprintMetadata::MD_AutoCreateRefTerm) || Pin->PinType.bIsArray);
const bool bAdvancedPin = Param->HasAllPropertyFlags(CPF_AdvancedDisplay);
Pin->bAdvancedView = bAdvancedPin;
if(bAdvancedPin && (ENodeAdvancedPins::NoPins == AdvancedPinDisplay))
{
AdvancedPinDisplay = ENodeAdvancedPins::Hidden;
}
FString MetadataDefaultValue = Function->GetMetaData(*Param->GetName());
if (!MetadataDefaultValue.IsEmpty())
{
// Specified default value in the metadata
Pin->DefaultValue = Pin->AutogeneratedDefaultValue = MetadataDefaultValue;
}
else
{
const FName MetadataCppDefaultValueKey( *(FString(TEXT("CPP_Default_")) + Param->GetName()) );
const FString MetadataCppDefaultValue = Function->GetMetaData(MetadataCppDefaultValueKey);
if(!MetadataCppDefaultValue.IsEmpty())
{
Pin->DefaultValue = Pin->AutogeneratedDefaultValue = MetadataCppDefaultValue;
}
else
{
// Set the default value to (T)0
K2Schema->SetPinDefaultValueBasedOnType(Pin);
}
}
if (PinsToHide.Contains(Pin->PinName))
{
Pin->bHidden = true;
Pin->DefaultValue = TEXT("0");
}
}
bAllPinsGood = bAllPinsGood && bPinGood;
}
}
Super::AllocateDefaultPins();
}
struct FBaseAsyncTaskHelper
{
static bool ValidDataPin(const UEdGraphPin* Pin, EEdGraphPinDirection Direction, const UEdGraphSchema_K2* Schema)
{
check(Schema);
const bool bValidDataPin = Pin
&& (Pin->PinName != Schema->PN_Execute)
&& (Pin->PinName != Schema->PN_Then)
&& (Pin->PinType.PinCategory != Schema->PC_Exec);
const bool bProperDirection = Pin && (Pin->Direction == Direction);
return bValidDataPin && bProperDirection;
}
static bool CreateDelegateForNewFunction(UEdGraphPin* DelegateInputPin, FName FunctionName, UK2Node* CurrentNode, UEdGraph* SourceGraph, FKismetCompilerContext& CompilerContext)
{
const UEdGraphSchema_K2* Schema = CompilerContext.GetSchema();
check(DelegateInputPin && Schema && CurrentNode && SourceGraph && (FunctionName != NAME_None));
bool bResult = true;
// WORKAROUND, so we can create delegate from nonexistent function by avoiding check at expanding step
// instead simply: Schema->TryCreateConnection(AddDelegateNode->GetDelegatePin(), CurrentCENode->FindPinChecked(UK2Node_CustomEvent::DelegateOutputName));
UK2Node_Self* SelfNode = CompilerContext.SpawnIntermediateNode<UK2Node_Self>(CurrentNode, SourceGraph);
SelfNode->AllocateDefaultPins();
UK2Node_CreateDelegate* CreateDelegateNode = CompilerContext.SpawnIntermediateNode<UK2Node_CreateDelegate>(CurrentNode, SourceGraph);
CreateDelegateNode->AllocateDefaultPins();
bResult &= Schema->TryCreateConnection(DelegateInputPin, CreateDelegateNode->GetDelegateOutPin());
bResult &= Schema->TryCreateConnection(SelfNode->FindPinChecked(Schema->PN_Self), CreateDelegateNode->GetObjectInPin());
CreateDelegateNode->SetFunction(FunctionName);
return bResult;
}
struct FOutputPinAndLocalVariable
{
UEdGraphPin* OutputPin;
UK2Node_TemporaryVariable* TempVar;
FOutputPinAndLocalVariable(UEdGraphPin* Pin, UK2Node_TemporaryVariable* Var) : OutputPin(Pin), TempVar(Var) {}
};
static bool CopyEventSignature(UK2Node_CustomEvent* CENode, UFunction* Function, const UEdGraphSchema_K2* Schema)
{
check(CENode && Function && Schema);
bool bResult = true;
for (TFieldIterator<UProperty> PropIt(Function); PropIt && (PropIt->PropertyFlags & CPF_Parm); ++PropIt)
{
const UProperty* Param = *PropIt;
if (!Param->HasAnyPropertyFlags(CPF_OutParm) || Param->HasAnyPropertyFlags(CPF_ReferenceParm))
{
FEdGraphPinType PinType;
bResult &= Schema->ConvertPropertyToPinType(Param, /*out*/ PinType);
bResult &= (NULL != CENode->CreateUserDefinedPin(Param->GetName(), PinType));
}
}
return bResult;
}
static bool HandleDelegateImplementation(
UMulticastDelegateProperty* CurrentProperty, const TArray<FBaseAsyncTaskHelper::FOutputPinAndLocalVariable>& VariableOutputs,
UEdGraphPin* ProxyObjectPin, UEdGraphPin*& InOutLastThenPin,
UK2Node* CurrentNode, UEdGraph* SourceGraph, FKismetCompilerContext& CompilerContext)
{
bool bIsErrorFree = true;
const UEdGraphSchema_K2* Schema = CompilerContext.GetSchema();
check(CurrentProperty && ProxyObjectPin && InOutLastThenPin && CurrentNode && SourceGraph && Schema);
UEdGraphPin* PinForCurrentDelegateProperty = CurrentNode->FindPin(CurrentProperty->GetName());
if (!PinForCurrentDelegateProperty || (Schema->PC_Exec != PinForCurrentDelegateProperty->PinType.PinCategory))
{
FText ErrorMessage = FText::Format(LOCTEXT("WrongDelegateProperty", "BaseAsyncTask: Cannot find execution pin for delegate "), FText::FromString(CurrentProperty->GetName()));
CompilerContext.MessageLog.Error(*ErrorMessage.ToString(), CurrentNode);
return false;
}
UK2Node_CustomEvent* CurrentCENode = CompilerContext.SpawnIntermediateNode<UK2Node_CustomEvent>(CurrentNode, SourceGraph);
{
UK2Node_AddDelegate* AddDelegateNode = CompilerContext.SpawnIntermediateNode<UK2Node_AddDelegate>(CurrentNode, SourceGraph);
AddDelegateNode->SetFromProperty(CurrentProperty, false);
AddDelegateNode->AllocateDefaultPins();
bIsErrorFree &= Schema->TryCreateConnection(AddDelegateNode->FindPinChecked(Schema->PN_Self), ProxyObjectPin);
bIsErrorFree &= Schema->TryCreateConnection(InOutLastThenPin, AddDelegateNode->FindPinChecked(Schema->PN_Execute));
InOutLastThenPin = AddDelegateNode->FindPinChecked(Schema->PN_Then);
CurrentCENode->CustomFunctionName = *FString::Printf(TEXT("%s_%s"), *CurrentProperty->GetName(), *CurrentCENode->NodeGuid.ToString());
CurrentCENode->AllocateDefaultPins();
bIsErrorFree &= FBaseAsyncTaskHelper::CreateDelegateForNewFunction(AddDelegateNode->GetDelegatePin(), CurrentCENode->GetFunctionName(), CurrentNode, SourceGraph, CompilerContext);
bIsErrorFree &= FBaseAsyncTaskHelper::CopyEventSignature(CurrentCENode, AddDelegateNode->GetDelegateSignature(), Schema);
}
UEdGraphPin* LastActivatedNodeThen = CurrentCENode->FindPinChecked(Schema->PN_Then);
for (auto OutputPair : VariableOutputs) // CREATE CHAIN OF ASSIGMENTS
{
UEdGraphPin* PinWithData = CurrentCENode->FindPin(OutputPair.OutputPin->PinName);
if (PinWithData == NULL)
{
FText ErrorMessage = FText::Format(LOCTEXT("MissingDataPin", "ICE: Pin @@ was expecting a data output pin named {0} on @@ (each delegate must have the same signature)"), FText::FromString(OutputPair.OutputPin->PinName));
CompilerContext.MessageLog.Error(*ErrorMessage.ToString(), OutputPair.OutputPin, CurrentCENode);
return false;
}
UK2Node_AssignmentStatement* AssignNode = CompilerContext.SpawnIntermediateNode<UK2Node_AssignmentStatement>(CurrentNode, SourceGraph);
AssignNode->AllocateDefaultPins();
bIsErrorFree &= Schema->TryCreateConnection(LastActivatedNodeThen, AssignNode->GetExecPin());
bIsErrorFree &= Schema->TryCreateConnection(OutputPair.TempVar->GetVariablePin(), AssignNode->GetVariablePin());
AssignNode->NotifyPinConnectionListChanged(AssignNode->GetVariablePin());
bIsErrorFree &= Schema->TryCreateConnection(AssignNode->GetValuePin(), PinWithData);
AssignNode->NotifyPinConnectionListChanged(AssignNode->GetValuePin());
LastActivatedNodeThen = AssignNode->GetThenPin();
}
bIsErrorFree &= CompilerContext.MovePinLinksToIntermediate(*PinForCurrentDelegateProperty, *LastActivatedNodeThen).CanSafeConnect();
return bIsErrorFree;
}
};
void UK2Node_BaseAsyncTask::ExpandNode(class FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph)
{
if (!CompilerContext.bIsFullCompile)
{
return;
}
const UEdGraphSchema_K2* Schema = CompilerContext.GetSchema();
check(SourceGraph && Schema);
bool bIsErrorFree = true;
// Create a call to factory the proxy object
UK2Node_CallFunction* const CallCreateProxyObjectNode = CompilerContext.SpawnIntermediateNode<UK2Node_CallFunction>(this, SourceGraph);
CallCreateProxyObjectNode->FunctionReference.SetExternalMember(ProxyFactoryFunctionName, ProxyFactoryClass);
CallCreateProxyObjectNode->AllocateDefaultPins();
bIsErrorFree &= CompilerContext.MovePinLinksToIntermediate(*FindPinChecked(Schema->PN_Execute), *CallCreateProxyObjectNode->FindPinChecked(Schema->PN_Execute)).CanSafeConnect();
for (auto CurrentPin : Pins)
{
if (FBaseAsyncTaskHelper::ValidDataPin(CurrentPin, EGPD_Input, Schema))
{
UEdGraphPin* DestPin = CallCreateProxyObjectNode->FindPin(CurrentPin->PinName); // match function inputs, to pass data to function from CallFunction node
bIsErrorFree &= DestPin && CompilerContext.MovePinLinksToIntermediate(*CurrentPin, *DestPin).CanSafeConnect();
}
}
// GATHER OUTPUT PARAMETERS AND PAIR THEM WITH LOCAL VARIABLES
TArray<FBaseAsyncTaskHelper::FOutputPinAndLocalVariable> VariableOutputs;
for (auto CurrentPin : Pins)
{
if (FBaseAsyncTaskHelper::ValidDataPin(CurrentPin, EGPD_Output, Schema))
{
const FEdGraphPinType& PinType = CurrentPin->PinType;
UK2Node_TemporaryVariable* TempVarOutput = CompilerContext.SpawnInternalVariable(
this, PinType.PinCategory, PinType.PinSubCategory, PinType.PinSubCategoryObject.Get(), PinType.bIsArray);
bIsErrorFree &= TempVarOutput->GetVariablePin() && CompilerContext.MovePinLinksToIntermediate(*CurrentPin, *TempVarOutput->GetVariablePin()).CanSafeConnect();
VariableOutputs.Add(FBaseAsyncTaskHelper::FOutputPinAndLocalVariable(CurrentPin, TempVarOutput));
}
}
// FOR EACH DELEGATE DEFINE EVENT, CONNECT IT TO DELEGATE AND IMPLEMENT A CHAIN OF ASSIGMENTS
UEdGraphPin* LastThenPin = CallCreateProxyObjectNode->FindPinChecked(Schema->PN_Then);
UEdGraphPin* const ProxyObjectPin = CallCreateProxyObjectNode->GetReturnValuePin();
for (TFieldIterator<UMulticastDelegateProperty> PropertyIt(ProxyClass, EFieldIteratorFlags::ExcludeSuper); PropertyIt && bIsErrorFree; ++PropertyIt)
{
bIsErrorFree &= FBaseAsyncTaskHelper::HandleDelegateImplementation(*PropertyIt, VariableOutputs, ProxyObjectPin, LastThenPin, this, SourceGraph, CompilerContext);
}
if (CallCreateProxyObjectNode->FindPinChecked(Schema->PN_Then) == LastThenPin)
{
CompilerContext.MessageLog.Error(*LOCTEXT("MissingDelegateProperties", "BaseAsyncTask: Proxy has no delegates defined. @@").ToString(), this);
return;
}
// Create a call to activate the proxy object if necessary
if (ProxyActivateFunctionName != NAME_None)
{
UK2Node_CallFunction* const CallActivateProxyObjectNode = CompilerContext.SpawnIntermediateNode<UK2Node_CallFunction>(this, SourceGraph);
CallActivateProxyObjectNode->FunctionReference.SetExternalMember(ProxyActivateFunctionName, ProxyClass);
CallActivateProxyObjectNode->AllocateDefaultPins();
// Hook up the self connection
UEdGraphPin* ActivateCallSelfPin = Schema->FindSelfPin(*CallActivateProxyObjectNode, EGPD_Input);
check(ActivateCallSelfPin);
bIsErrorFree &= Schema->TryCreateConnection(ProxyObjectPin, ActivateCallSelfPin);
// Hook the activate node up in the exec chain
UEdGraphPin* ActivateExecPin = CallActivateProxyObjectNode->FindPinChecked(Schema->PN_Execute);
UEdGraphPin* ActivateThenPin = CallActivateProxyObjectNode->FindPinChecked(Schema->PN_Then);
bIsErrorFree &= Schema->TryCreateConnection(LastThenPin, ActivateExecPin);
LastThenPin = ActivateThenPin;
}
// Move the connections from the original node then pin to the last internal then pin
bIsErrorFree &= CompilerContext.MovePinLinksToIntermediate(*FindPinChecked(Schema->PN_Then), *LastThenPin).CanSafeConnect();
if (!bIsErrorFree)
{
CompilerContext.MessageLog.Error(*LOCTEXT("InternalConnectionError", "BaseAsyncTask: Internal connection error. @@").ToString(), this);
}
// Make sure we caught everything
BreakAllNodeLinks();
}
bool UK2Node_BaseAsyncTask::HasExternalBlueprintDependencies(TArray<class UStruct*>* OptionalOutput) const
{
const UBlueprint* SourceBlueprint = GetBlueprint();
const bool bProxyFactoryResult = (ProxyFactoryClass != NULL) && (ProxyFactoryClass->ClassGeneratedBy != NULL) && (ProxyFactoryClass->ClassGeneratedBy != SourceBlueprint);
if (bProxyFactoryResult && OptionalOutput)
{
OptionalOutput->Add(ProxyFactoryClass);
}
const bool bProxyResult = (ProxyClass != NULL) && (ProxyClass->ClassGeneratedBy != NULL) && (ProxyClass->ClassGeneratedBy != SourceBlueprint);
if (bProxyResult && OptionalOutput)
{
OptionalOutput->Add(ProxyClass);
}
return bProxyFactoryResult || bProxyResult || Super::HasExternalBlueprintDependencies(OptionalOutput);
}
FName UK2Node_BaseAsyncTask::GetCornerIcon() const
{
return TEXT("Graph.Latent.LatentIcon");
}
UFunction* UK2Node_BaseAsyncTask::GetFactoryFunction() const
{
check(ProxyFactoryClass);
UFunction* FactoryFunction = ProxyFactoryClass->FindFunctionByName(ProxyFactoryFunctionName);
check(FactoryFunction);
return FactoryFunction;
}
#undef LOCTEXT_NAMESPACE