2014-12-07 19:09:38 -05:00
|
|
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
2014-10-09 06:06:10 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "BlueprintGraphPrivatePCH.h"
|
|
|
|
|
#include "KismetCompiler.h"
|
|
|
|
|
#include "VariableSetHandler.h"
|
|
|
|
|
#include "BlueprintNodeSpawner.h"
|
|
|
|
|
#include "EditorCategoryUtils.h"
|
|
|
|
|
#include "K2Node_PureAssignmentStatement.h"
|
|
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "K2Node_PureAssignmentStatement"
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// FKCHandler_PureAssignmentStatement
|
|
|
|
|
|
|
|
|
|
class FKCHandler_PureAssignmentStatement : public FKCHandler_VariableSet
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
FKCHandler_PureAssignmentStatement(FKismetCompilerContext& InCompilerContext)
|
|
|
|
|
: FKCHandler_VariableSet(InCompilerContext)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void RegisterNets(FKismetFunctionContext& Context, UEdGraphNode* Node) override
|
|
|
|
|
{
|
|
|
|
|
auto PureAssignmentNode = CastChecked<UK2Node_PureAssignmentStatement>(Node);
|
|
|
|
|
{
|
|
|
|
|
auto VariablePin = PureAssignmentNode->GetVariablePin();
|
|
|
|
|
if (VariablePin->LinkedTo.Num() == 0)
|
|
|
|
|
{
|
|
|
|
|
CompilerContext.MessageLog.Error(*LOCTEXT("NoVarriableConnected_Error", "A variable needs to be connected to @@").ToString(), VariablePin);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto OutputPin = PureAssignmentNode->GetOutputPin();
|
|
|
|
|
if (OutputPin->LinkedTo.Num() == 0)
|
|
|
|
|
{
|
|
|
|
|
CompilerContext.MessageLog.Error(*LOCTEXT("NoVarriableConnected_Error", "A output pin needs to be connected to @@").ToString(), OutputPin);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// At the moment, a term for variable should be already registered
|
2015-03-03 16:55:12 -05:00
|
|
|
auto VariableTermPtr = Context.NetMap.Find(FEdGraphUtilities::GetNetFromPin(VariablePin));
|
|
|
|
|
if (!VariableTermPtr || !*VariableTermPtr)
|
2014-10-09 06:06:10 -04:00
|
|
|
{
|
|
|
|
|
CompilerContext.MessageLog.Error(*LOCTEXT("NoVarriableTerm_Error", "ICE: no variable term found in @@").ToString(), Node);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-03-03 16:55:12 -05:00
|
|
|
FBPTerminal* VariableTerm = *VariableTermPtr; // we must take a copy here because Add takes a reference and the map might be resized
|
|
|
|
|
Context.NetMap.Add(OutputPin, VariableTerm);
|
2014-10-09 06:06:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto ValuePin = PureAssignmentNode->GetValuePin();
|
|
|
|
|
ValidateAndRegisterNetIfLiteral(Context, ValuePin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void Compile(FKismetFunctionContext& Context, UEdGraphNode* Node) override
|
|
|
|
|
{
|
|
|
|
|
auto PureAssignmentNode = CastChecked<UK2Node_PureAssignmentStatement>(Node);
|
|
|
|
|
auto VariablePin = PureAssignmentNode->GetVariablePin();
|
|
|
|
|
auto ValuePin = PureAssignmentNode->GetValuePin();
|
|
|
|
|
|
|
|
|
|
InnerAssignment(Context, Node, VariablePin, ValuePin);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// The node is (was originally) needed in expansion step for handling CreateAutoRefTerm parameters in pure functions
|
|
|
|
|
|
|
|
|
|
FString UK2Node_PureAssignmentStatement::VariablePinName = FString(TEXT("Variable"));
|
|
|
|
|
FString UK2Node_PureAssignmentStatement::ValuePinName = FString(TEXT("Value"));
|
|
|
|
|
FString UK2Node_PureAssignmentStatement::OutputPinName = FString(TEXT("ReturnValue"));
|
|
|
|
|
|
|
|
|
|
|
2014-10-14 10:29:11 -04:00
|
|
|
UK2Node_PureAssignmentStatement::UK2Node_PureAssignmentStatement(const FObjectInitializer& ObjectInitializer)
|
|
|
|
|
: Super(ObjectInitializer)
|
2014-10-09 06:06:10 -04:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UK2Node_PureAssignmentStatement::AllocateDefaultPins()
|
|
|
|
|
{
|
|
|
|
|
const UEdGraphSchema_K2* Schema = GetDefault<UEdGraphSchema_K2>();
|
|
|
|
|
|
|
|
|
|
CreatePin(EGPD_Input, Schema->PC_Wildcard, TEXT(""), NULL, false, false, VariablePinName);
|
|
|
|
|
CreatePin(EGPD_Input, Schema->PC_Wildcard, TEXT(""), NULL, false, false, ValuePinName);
|
|
|
|
|
CreatePin(EGPD_Output, Schema->PC_Wildcard, TEXT(""), NULL, false, false, OutputPinName);
|
|
|
|
|
|
|
|
|
|
Super::AllocateDefaultPins();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UK2Node_PureAssignmentStatement::NotifyPinConnectionListChanged(UEdGraphPin* Pin)
|
|
|
|
|
{
|
|
|
|
|
Super::NotifyPinConnectionListChanged(Pin);
|
|
|
|
|
|
|
|
|
|
if (Pin->LinkedTo.Num() > 0)
|
|
|
|
|
{
|
|
|
|
|
const auto PinType = Pin->LinkedTo[0]->PinType;
|
|
|
|
|
|
|
|
|
|
auto VariablePin = GetVariablePin();
|
|
|
|
|
VariablePin->PinType = PinType;
|
|
|
|
|
UEdGraphSchema_K2::ValidateExistingConnections(VariablePin);
|
|
|
|
|
|
|
|
|
|
auto OutputPin = GetOutputPin();
|
|
|
|
|
OutputPin->PinType = PinType;
|
|
|
|
|
UEdGraphSchema_K2::ValidateExistingConnections(OutputPin);
|
|
|
|
|
|
|
|
|
|
auto ValuePin = GetValuePin();
|
|
|
|
|
ValuePin->PinType = PinType;
|
|
|
|
|
ValuePin->PinType.bIsReference = false;
|
|
|
|
|
UEdGraphSchema_K2::ValidateExistingConnections(ValuePin);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UEdGraphPin* UK2Node_PureAssignmentStatement::GetOutputPin() const
|
|
|
|
|
{
|
|
|
|
|
return FindPinChecked(OutputPinName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UEdGraphPin* UK2Node_PureAssignmentStatement::GetVariablePin() const
|
|
|
|
|
{
|
|
|
|
|
return FindPinChecked(VariablePinName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UEdGraphPin* UK2Node_PureAssignmentStatement::GetValuePin() const
|
|
|
|
|
{
|
|
|
|
|
return FindPinChecked(ValuePinName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FNodeHandlingFunctor* UK2Node_PureAssignmentStatement::CreateNodeHandler(FKismetCompilerContext& CompilerContext) const
|
|
|
|
|
{
|
|
|
|
|
return new FKCHandler_PureAssignmentStatement(CompilerContext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|