You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
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 Change2030016by 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 Change2034181by 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]
481 lines
18 KiB
C++
481 lines
18 KiB
C++
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "BlueprintGraphPrivatePCH.h"
|
|
#include "KismetCompiler.h"
|
|
#include "Runtime/Engine/Classes/Kismet/GameplayStatics.h"
|
|
|
|
struct FK2Node_SpawnActorFromClassHelper
|
|
{
|
|
static FString WorldContextPinName;
|
|
static FString ClassPinName;
|
|
static FString SpawnTransformPinName;
|
|
static FString NoCollisionFailPinName;
|
|
};
|
|
|
|
FString FK2Node_SpawnActorFromClassHelper::WorldContextPinName(TEXT("WorldContextObject"));
|
|
FString FK2Node_SpawnActorFromClassHelper::ClassPinName(TEXT("Class"));
|
|
FString FK2Node_SpawnActorFromClassHelper::SpawnTransformPinName(TEXT("SpawnTransform"));
|
|
FString FK2Node_SpawnActorFromClassHelper::NoCollisionFailPinName(TEXT("SpawnEvenIfColliding"));
|
|
|
|
#define LOCTEXT_NAMESPACE "K2Node_SpawnActorFromClass"
|
|
|
|
UK2Node_SpawnActorFromClass::UK2Node_SpawnActorFromClass(const class FPostConstructInitializeProperties& PCIP)
|
|
: Super(PCIP)
|
|
{
|
|
NodeTooltip = LOCTEXT("NodeTooltip", "Attempts to spawn a new Actor with the specified transform").ToString();
|
|
}
|
|
|
|
void UK2Node_SpawnActorFromClass::AllocateDefaultPins()
|
|
{
|
|
const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();
|
|
|
|
// Add execution pins
|
|
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);
|
|
|
|
// If required add the world context pin
|
|
if (GetBlueprint()->ParentClass->HasMetaData(FBlueprintMetadata::MD_ShowHiddenSelfPins))
|
|
{
|
|
CreatePin(EGPD_Input, K2Schema->PC_Object, TEXT(""), UObject::StaticClass(), false, false, FK2Node_SpawnActorFromClassHelper::WorldContextPinName);
|
|
}
|
|
|
|
// Add blueprint pin
|
|
UEdGraphPin* ClassPin = CreatePin(EGPD_Input, K2Schema->PC_Class, TEXT(""), AActor::StaticClass(), false, false, FK2Node_SpawnActorFromClassHelper::ClassPinName);
|
|
SetPinToolTip(*ClassPin, LOCTEXT("ClassPinDescription", "The Actor class you want to spawn"));
|
|
|
|
// Transform pin
|
|
UScriptStruct* TransformStruct = FindObjectChecked<UScriptStruct>(UObject::StaticClass(), TEXT("Transform"));
|
|
UEdGraphPin* TransformPin = CreatePin(EGPD_Input, K2Schema->PC_Struct, TEXT(""), TransformStruct, false, false, FK2Node_SpawnActorFromClassHelper::SpawnTransformPinName);
|
|
SetPinToolTip(*TransformPin, LOCTEXT("TransformPinDescription", "The transform to spawn the Actor with"));
|
|
|
|
// bNoCollisionFail pin
|
|
UEdGraphPin* NoCollisionFailPin = CreatePin(EGPD_Input, K2Schema->PC_Boolean, TEXT(""), NULL, false, false, FK2Node_SpawnActorFromClassHelper::NoCollisionFailPinName);
|
|
SetPinToolTip(*NoCollisionFailPin, LOCTEXT("NoCollisionFailPinDescription", "Determines if the Actor should be spawned when the location is blocked by a collision"));
|
|
|
|
// Result pin
|
|
UEdGraphPin* ResultPin = CreatePin(EGPD_Output, K2Schema->PC_Object, TEXT(""), AActor::StaticClass(), false, false, K2Schema->PN_ReturnValue);
|
|
SetPinToolTip(*ResultPin, LOCTEXT("ResultPinDescription", "The spawned Actor"));
|
|
|
|
Super::AllocateDefaultPins();
|
|
}
|
|
|
|
void UK2Node_SpawnActorFromClass::SetPinToolTip(UEdGraphPin& MutatablePin, const FText& PinDescription) const
|
|
{
|
|
MutatablePin.PinToolTip = UEdGraphSchema_K2::TypeToString(MutatablePin.PinType);
|
|
|
|
UEdGraphSchema_K2 const* const K2Schema = Cast<const UEdGraphSchema_K2>(GetSchema());
|
|
if (K2Schema != nullptr)
|
|
{
|
|
MutatablePin.PinToolTip += TEXT(" ");
|
|
MutatablePin.PinToolTip += K2Schema->GetPinDisplayName(&MutatablePin);
|
|
}
|
|
|
|
MutatablePin.PinToolTip += FString(TEXT("\n")) + PinDescription.ToString();
|
|
}
|
|
|
|
|
|
void UK2Node_SpawnActorFromClass::CreatePinsForClass(UClass* InClass)
|
|
{
|
|
check(InClass != NULL);
|
|
|
|
const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();
|
|
|
|
for (TFieldIterator<UProperty> PropertyIt(InClass, EFieldIteratorFlags::IncludeSuper); PropertyIt; ++PropertyIt)
|
|
{
|
|
UProperty* Property = *PropertyIt;
|
|
UClass* PropertyClass = CastChecked<UClass>(Property->GetOuter());
|
|
const bool bIsDelegate = Property->IsA(UMulticastDelegateProperty::StaticClass());
|
|
const bool bIsExposedToSpawn = UEdGraphSchema_K2::IsPropertyExposedOnSpawn(Property);
|
|
const bool bIsSettableExternally = !Property->HasAnyPropertyFlags(CPF_DisableEditOnInstance);
|
|
|
|
if( bIsExposedToSpawn &&
|
|
!Property->HasAnyPropertyFlags(CPF_Parm) &&
|
|
bIsSettableExternally &&
|
|
Property->HasAllPropertyFlags(CPF_BlueprintVisible) &&
|
|
!bIsDelegate )
|
|
{
|
|
UEdGraphPin* Pin = CreatePin(EGPD_Input, TEXT(""), TEXT(""), NULL, false, false, Property->GetName());
|
|
const bool bPinGood = (Pin != NULL) && K2Schema->ConvertPropertyToPinType(Property, /*out*/ Pin->PinType);
|
|
Pin->bDefaultValueIsIgnored = true;
|
|
}
|
|
}
|
|
|
|
// Change class of output pin
|
|
UEdGraphPin* ResultPin = GetResultPin();
|
|
ResultPin->PinType.PinSubCategoryObject = InClass;
|
|
}
|
|
|
|
UClass* UK2Node_SpawnActorFromClass::GetClassToSpawn(const TArray<UEdGraphPin*>* InPinsToSearch /*=NULL*/) const
|
|
{
|
|
UClass* UseSpawnClass = NULL;
|
|
const TArray<UEdGraphPin*>* PinsToSearch = InPinsToSearch ? InPinsToSearch : &Pins;
|
|
|
|
UEdGraphPin* ClassPin = GetClassPin(PinsToSearch);
|
|
if(ClassPin && ClassPin->DefaultObject != NULL && ClassPin->LinkedTo.Num() == 0)
|
|
{
|
|
UseSpawnClass = CastChecked<UClass>(ClassPin->DefaultObject);
|
|
}
|
|
|
|
return UseSpawnClass;
|
|
}
|
|
|
|
|
|
void UK2Node_SpawnActorFromClass::ReallocatePinsDuringReconstruction(TArray<UEdGraphPin*>& OldPins)
|
|
{
|
|
AllocateDefaultPins();
|
|
UClass* UseSpawnClass = GetClassToSpawn(&OldPins);
|
|
if( UseSpawnClass != NULL )
|
|
{
|
|
CreatePinsForClass(UseSpawnClass);
|
|
}
|
|
}
|
|
|
|
bool UK2Node_SpawnActorFromClass::IsSpawnVarPin(UEdGraphPin* Pin)
|
|
{
|
|
const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();
|
|
|
|
return( Pin->PinName != K2Schema->PN_Execute &&
|
|
Pin->PinName != K2Schema->PN_Then &&
|
|
Pin->PinName != K2Schema->PN_ReturnValue &&
|
|
Pin->PinName != FK2Node_SpawnActorFromClassHelper::ClassPinName &&
|
|
Pin->PinName != FK2Node_SpawnActorFromClassHelper::WorldContextPinName &&
|
|
Pin->PinName != FK2Node_SpawnActorFromClassHelper::NoCollisionFailPinName &&
|
|
Pin->PinName != FK2Node_SpawnActorFromClassHelper::SpawnTransformPinName );
|
|
}
|
|
|
|
|
|
void UK2Node_SpawnActorFromClass::PinDefaultValueChanged(UEdGraphPin* ChangedPin)
|
|
{
|
|
if (ChangedPin->PinName == FK2Node_SpawnActorFromClassHelper::ClassPinName)
|
|
{
|
|
const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();
|
|
|
|
// Because the archetype has changed, we break the output link as the output pin type will change
|
|
UEdGraphPin* ResultPin = GetResultPin();
|
|
ResultPin->BreakAllPinLinks();
|
|
|
|
// Remove all pins related to archetype variables
|
|
TArray<UEdGraphPin*> OldPins = Pins;
|
|
for (int32 i = 0; i < OldPins.Num(); i++)
|
|
{
|
|
UEdGraphPin* OldPin = OldPins[i];
|
|
if (IsSpawnVarPin(OldPin))
|
|
{
|
|
OldPin->BreakAllPinLinks();
|
|
Pins.Remove(OldPin);
|
|
}
|
|
}
|
|
|
|
UClass* UseSpawnClass = GetClassToSpawn();
|
|
if (UseSpawnClass != NULL)
|
|
{
|
|
CreatePinsForClass(UseSpawnClass);
|
|
}
|
|
|
|
// Refresh the UI for the graph so the pin changes show up
|
|
UEdGraph* Graph = GetGraph();
|
|
Graph->NotifyGraphChanged();
|
|
|
|
// Mark dirty
|
|
FBlueprintEditorUtils::MarkBlueprintAsModified(GetBlueprint());
|
|
}
|
|
}
|
|
|
|
FString UK2Node_SpawnActorFromClass::GetTooltip() const
|
|
{
|
|
return NodeTooltip;
|
|
}
|
|
|
|
UEdGraphPin* UK2Node_SpawnActorFromClass::GetThenPin()const
|
|
{
|
|
const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();
|
|
|
|
UEdGraphPin* Pin = FindPinChecked(K2Schema->PN_Then);
|
|
check(Pin->Direction == EGPD_Output);
|
|
return Pin;
|
|
}
|
|
|
|
UEdGraphPin* UK2Node_SpawnActorFromClass::GetClassPin(const TArray<UEdGraphPin*>* InPinsToSearch /*= NULL*/) const
|
|
{
|
|
const TArray<UEdGraphPin*>* PinsToSearch = InPinsToSearch ? InPinsToSearch : &Pins;
|
|
|
|
UEdGraphPin* Pin = NULL;
|
|
for( auto PinIt = PinsToSearch->CreateConstIterator(); PinIt; ++PinIt )
|
|
{
|
|
UEdGraphPin* TestPin = *PinIt;
|
|
if( TestPin && TestPin->PinName == FK2Node_SpawnActorFromClassHelper::ClassPinName )
|
|
{
|
|
Pin = TestPin;
|
|
break;
|
|
}
|
|
}
|
|
check(Pin == NULL || Pin->Direction == EGPD_Input);
|
|
return Pin;
|
|
}
|
|
|
|
UEdGraphPin* UK2Node_SpawnActorFromClass::GetSpawnTransformPin() const
|
|
{
|
|
UEdGraphPin* Pin = FindPinChecked(FK2Node_SpawnActorFromClassHelper::SpawnTransformPinName);
|
|
check(Pin->Direction == EGPD_Input);
|
|
return Pin;
|
|
}
|
|
|
|
|
|
UEdGraphPin* UK2Node_SpawnActorFromClass::GetNoCollisionFailPin() const
|
|
{
|
|
UEdGraphPin* Pin = FindPinChecked(FK2Node_SpawnActorFromClassHelper::NoCollisionFailPinName);
|
|
check(Pin->Direction == EGPD_Input);
|
|
return Pin;
|
|
}
|
|
|
|
UEdGraphPin* UK2Node_SpawnActorFromClass::GetWorldContextPin() const
|
|
{
|
|
UEdGraphPin* Pin = FindPin(FK2Node_SpawnActorFromClassHelper::WorldContextPinName);
|
|
check(Pin == NULL || Pin->Direction == EGPD_Input);
|
|
return Pin;
|
|
}
|
|
|
|
UEdGraphPin* UK2Node_SpawnActorFromClass::GetResultPin() const
|
|
{
|
|
const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();
|
|
|
|
UEdGraphPin* Pin = FindPinChecked(K2Schema->PN_ReturnValue);
|
|
check(Pin->Direction == EGPD_Output);
|
|
return Pin;
|
|
}
|
|
|
|
FLinearColor UK2Node_SpawnActorFromClass::GetNodeTitleColor() const
|
|
{
|
|
return Super::GetNodeTitleColor();
|
|
}
|
|
|
|
|
|
FText UK2Node_SpawnActorFromClass::GetNodeTitle(ENodeTitleType::Type TitleType) const
|
|
{
|
|
UEdGraphPin* ClassPin = GetClassPin();
|
|
|
|
FText SpawnString = NSLOCTEXT("K2Node", "None", "NONE");
|
|
if(ClassPin != NULL)
|
|
{
|
|
if(ClassPin->LinkedTo.Num() > 0)
|
|
{
|
|
// Blueprint will be determined dynamically, so we don't have the name in this case
|
|
SpawnString = FText::GetEmpty();
|
|
}
|
|
else if(ClassPin->DefaultObject != NULL)
|
|
{
|
|
SpawnString = FText::FromString(ClassPin->DefaultObject->GetName());
|
|
}
|
|
}
|
|
|
|
FFormatNamedArguments Args;
|
|
Args.Add(TEXT("ClassName"), SpawnString);
|
|
return FText::Format(NSLOCTEXT("K2Node", "SpawnActor", "SpawnActor {ClassName}"), Args);
|
|
}
|
|
|
|
FString UK2Node_SpawnActorFromClass::GetNodeNativeTitle(ENodeTitleType::Type TitleType) const
|
|
{
|
|
// Do not setup this function for localization, intentionally left unlocalized!
|
|
|
|
UEdGraphPin* ClassPin = GetClassPin();
|
|
|
|
FString SpawnString = TEXT("NONE");
|
|
if(ClassPin != NULL)
|
|
{
|
|
if(ClassPin->LinkedTo.Num() > 0)
|
|
{
|
|
// Blueprint will be determined dynamically, so we don't have the name in this case
|
|
SpawnString = TEXT("");
|
|
}
|
|
else if(ClassPin->DefaultObject != NULL)
|
|
{
|
|
SpawnString = ClassPin->DefaultObject->GetName();
|
|
}
|
|
}
|
|
|
|
return FString::Printf(TEXT("SpawnActor %s"), *SpawnString);
|
|
}
|
|
|
|
bool UK2Node_SpawnActorFromClass::CanPasteHere( const UEdGraph* TargetGraph, const UEdGraphSchema* Schema ) const
|
|
{
|
|
UBlueprint* Blueprint = Cast<UBlueprint>(TargetGraph->GetOuter());
|
|
return CanCreateUnderSpecifiedSchema(Schema) && (!Blueprint || FBlueprintEditorUtils::FindUserConstructionScript(Blueprint) != TargetGraph);
|
|
}
|
|
|
|
void UK2Node_SpawnActorFromClass::ExpandNode(class FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph)
|
|
{
|
|
Super::ExpandNode(CompilerContext, SourceGraph);
|
|
|
|
if (CompilerContext.bIsFullCompile)
|
|
{
|
|
static FName BeginSpawningBlueprintFuncName = GET_FUNCTION_NAME_CHECKED(UGameplayStatics, BeginSpawningActorFromClass);
|
|
static FString ActorClassParamName = FString(TEXT("ActorClass"));
|
|
static FString WorldContextParamName = FString(TEXT("WorldContextObject"));
|
|
|
|
static FName FinishSpawningFuncName = GET_FUNCTION_NAME_CHECKED(UGameplayStatics, FinishSpawningActor);
|
|
static FString ActorParamName = FString(TEXT("Actor"));
|
|
static FString TransformParamName = FString(TEXT("SpawnTransform"));
|
|
static FString NoCollisionFailParamName = FString(TEXT("bNoCollisionFail"));
|
|
|
|
static FString ObjectParamName = FString(TEXT("Object"));
|
|
static FString ValueParamName = FString(TEXT("Value"));
|
|
static FString PropertyNameParamName = FString(TEXT("PropertyName"));
|
|
|
|
const UEdGraphSchema_K2* Schema = CompilerContext.GetSchema();
|
|
|
|
UK2Node_SpawnActorFromClass* SpawnNode = this;
|
|
UEdGraphPin* SpawnNodeExec = SpawnNode->GetExecPin();
|
|
UEdGraphPin* SpawnNodeTransform = SpawnNode->GetSpawnTransformPin();
|
|
UEdGraphPin* SpawnNodeNoCollisionFail = GetNoCollisionFailPin();
|
|
UEdGraphPin* SpawnWorldContextPin = SpawnNode->GetWorldContextPin();
|
|
UEdGraphPin* SpawnClassPin = SpawnNode->GetClassPin();
|
|
UEdGraphPin* SpawnNodeThen = SpawnNode->GetThenPin();
|
|
UEdGraphPin* SpawnNodeResult = SpawnNode->GetResultPin();
|
|
|
|
UClass* SpawnClass = (SpawnClassPin != NULL) ? Cast<UClass>(SpawnClassPin->DefaultObject) : NULL;
|
|
if((0 == SpawnClassPin->LinkedTo.Num()) && (NULL == SpawnClass))
|
|
{
|
|
CompilerContext.MessageLog.Error(*LOCTEXT("SpawnActorNodeMissingClass_Error", "Spawn node @@ must have a class specified.").ToString(), SpawnNode);
|
|
// we break exec links so this is the only error we get, don't want the SpawnActor node being considered and giving 'unexpected node' type warnings
|
|
SpawnNode->BreakAllNodeLinks();
|
|
return;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// create 'begin spawn' call node
|
|
UK2Node_CallFunction* CallBeginSpawnNode = CompilerContext.SpawnIntermediateNode<UK2Node_CallFunction>(SpawnNode, SourceGraph);
|
|
CallBeginSpawnNode->FunctionReference.SetExternalMember(BeginSpawningBlueprintFuncName, UGameplayStatics::StaticClass());
|
|
CallBeginSpawnNode->AllocateDefaultPins();
|
|
|
|
UEdGraphPin* CallBeginExec = CallBeginSpawnNode->GetExecPin();
|
|
UEdGraphPin* CallBeginWorldContextPin = CallBeginSpawnNode->FindPinChecked(WorldContextParamName);
|
|
UEdGraphPin* CallBeginActorClassPin = CallBeginSpawnNode->FindPinChecked(ActorClassParamName);
|
|
UEdGraphPin* CallBeginTransform = CallBeginSpawnNode->FindPinChecked(TransformParamName);
|
|
UEdGraphPin* CallBeginNoCollisionFail = CallBeginSpawnNode->FindPinChecked(NoCollisionFailParamName);
|
|
UEdGraphPin* CallBeginResult = CallBeginSpawnNode->GetReturnValuePin();
|
|
|
|
// Move 'exec' connection from spawn node to 'begin spawn'
|
|
CompilerContext.MovePinLinksToIntermediate(*SpawnNodeExec, *CallBeginExec);
|
|
|
|
if(SpawnClassPin->LinkedTo.Num() > 0)
|
|
{
|
|
// Copy the 'blueprint' connection from the spawn node to 'begin spawn'
|
|
CompilerContext.MovePinLinksToIntermediate(*SpawnClassPin, *CallBeginActorClassPin);
|
|
}
|
|
else
|
|
{
|
|
// Copy blueprint literal onto begin spawn call
|
|
CallBeginActorClassPin->DefaultObject = SpawnClass;
|
|
}
|
|
|
|
// Copy the world context connection from the spawn node to 'begin spawn' if necessary
|
|
if (SpawnWorldContextPin)
|
|
{
|
|
CompilerContext.MovePinLinksToIntermediate(*SpawnWorldContextPin, *CallBeginWorldContextPin);
|
|
}
|
|
|
|
// Copy the 'transform' connection from the spawn node to 'begin spawn'
|
|
CompilerContext.MovePinLinksToIntermediate(*SpawnNodeTransform, *CallBeginTransform);
|
|
|
|
// Copy the 'bNoCollisionFail' connection from the spawn node to 'begin spawn'
|
|
CompilerContext.MovePinLinksToIntermediate(*SpawnNodeNoCollisionFail, *CallBeginNoCollisionFail);
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// create 'finish spawn' call node
|
|
UK2Node_CallFunction* CallFinishSpawnNode = CompilerContext.SpawnIntermediateNode<UK2Node_CallFunction>(SpawnNode, SourceGraph);
|
|
CallFinishSpawnNode->FunctionReference.SetExternalMember(FinishSpawningFuncName, UGameplayStatics::StaticClass());
|
|
CallFinishSpawnNode->AllocateDefaultPins();
|
|
|
|
UEdGraphPin* CallFinishExec = CallFinishSpawnNode->GetExecPin();
|
|
UEdGraphPin* CallFinishThen = CallFinishSpawnNode->GetThenPin();
|
|
UEdGraphPin* CallFinishActor = CallFinishSpawnNode->FindPinChecked(ActorParamName);
|
|
UEdGraphPin* CallFinishTransform = CallFinishSpawnNode->FindPinChecked(TransformParamName);
|
|
UEdGraphPin* CallFinishResult = CallFinishSpawnNode->GetReturnValuePin();
|
|
|
|
// Move 'then' connection from spawn node to 'finish spawn'
|
|
CompilerContext.MovePinLinksToIntermediate(*SpawnNodeThen, *CallFinishThen);
|
|
|
|
// Copy transform connection
|
|
CompilerContext.CopyPinLinksToIntermediate(*CallBeginTransform, *CallFinishTransform);
|
|
|
|
// Connect output actor from 'begin' to 'finish'
|
|
CallBeginResult->MakeLinkTo(CallFinishActor);
|
|
|
|
// Move result connection from spawn node to 'finish spawn'
|
|
CallFinishResult->PinType = SpawnNodeResult->PinType; // Copy type so it uses the right actor subclass
|
|
CompilerContext.MovePinLinksToIntermediate(*SpawnNodeResult, *CallFinishResult);
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// create 'set var' nodes
|
|
|
|
// Get 'result' pin from 'begin spawn', this is the actual actor we want to set properties on
|
|
UK2Node_CallFunction* LastNode = CallBeginSpawnNode;
|
|
|
|
// Create 'set var by name' nodes and hook them up
|
|
for(int32 PinIdx=0; PinIdx < SpawnNode->Pins.Num(); PinIdx++)
|
|
{
|
|
// Only create 'set param by name' node if this pin is linked to something
|
|
UEdGraphPin* SpawnVarPin = SpawnNode->Pins[PinIdx];
|
|
if(SpawnVarPin->LinkedTo.Num() > 0)
|
|
{
|
|
UFunction* SetByNameFunction = Schema->FindSetVariableByNameFunction(SpawnVarPin->PinType);
|
|
if(SetByNameFunction)
|
|
{
|
|
UK2Node_CallFunction* SetVarNode = NULL;
|
|
if(SpawnVarPin->PinType.bIsArray)
|
|
{
|
|
SetVarNode = CompilerContext.SpawnIntermediateNode<UK2Node_CallArrayFunction>(SpawnNode, SourceGraph);
|
|
}
|
|
else
|
|
{
|
|
SetVarNode = CompilerContext.SpawnIntermediateNode<UK2Node_CallFunction>(SpawnNode, SourceGraph);
|
|
}
|
|
SetVarNode->SetFromFunction(SetByNameFunction);
|
|
SetVarNode->AllocateDefaultPins();
|
|
|
|
// Connect this node into the exec chain
|
|
UEdGraphPin* LastThen = LastNode->GetThenPin();
|
|
UEdGraphPin* SetVarExec = SetVarNode->GetExecPin();
|
|
LastThen->MakeLinkTo(SetVarExec);
|
|
|
|
// Connect the new actor to the 'object' pin
|
|
UEdGraphPin* ObjectPin = SetVarNode->FindPinChecked(ObjectParamName);
|
|
CallBeginResult->MakeLinkTo(ObjectPin);
|
|
|
|
// Fill in literal for 'property name' pin - name of pin is property name
|
|
UEdGraphPin* PropertyNamePin = SetVarNode->FindPinChecked(PropertyNameParamName);
|
|
PropertyNamePin->DefaultValue = SpawnVarPin->PinName;
|
|
|
|
// Move connection from the variable pin on the spawn node to the 'value' pin
|
|
UEdGraphPin* ValuePin = SetVarNode->FindPinChecked(ValueParamName);
|
|
CompilerContext.MovePinLinksToIntermediate(*SpawnVarPin, *ValuePin);
|
|
SetVarNode->PinConnectionListChanged(ValuePin);
|
|
|
|
// Update 'last node in sequence' var
|
|
LastNode = SetVarNode;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Make exec connection between 'then' on last node and 'finish'
|
|
UEdGraphPin* LastThen = LastNode->GetThenPin();
|
|
LastThen->MakeLinkTo(CallFinishExec);
|
|
|
|
// Break any links to the expanded node
|
|
SpawnNode->BreakAllNodeLinks();
|
|
}
|
|
}
|
|
|
|
bool UK2Node_SpawnActorFromClass::HasExternalBlueprintDependencies(TArray<class UStruct*>* OptionalOutput) const
|
|
{
|
|
UClass* SourceClass = GetClassToSpawn();
|
|
const UBlueprint* SourceBlueprint = GetBlueprint();
|
|
const bool bResult = (SourceClass != NULL) && (SourceClass->ClassGeneratedBy != NULL) && (SourceClass->ClassGeneratedBy != SourceBlueprint);
|
|
if (bResult && OptionalOutput)
|
|
{
|
|
OptionalOutput->Add(SourceClass);
|
|
}
|
|
return bResult || Super::HasExternalBlueprintDependencies(OptionalOutput);
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE |