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("NoVariableConnected_Error", "A variable needs to be connected to @@").ToString(), VariablePin);
				return;
			}

			auto OutputPin = PureAssignmentNode->GetOutputPin();
			if (OutputPin->LinkedTo.Num() == 0)
			{
				CompilerContext.MessageLog.Error(*LOCTEXT("NoOutputConnected_Error", "A output pin needs to be connected to @@").ToString(), OutputPin);
				return;
			}

			// At the moment, a term for variable should be already registered
			auto VariableTermPtr = Context.NetMap.Find(FEdGraphUtilities::GetNetFromPin(VariablePin));
			if (!VariableTermPtr || !*VariableTermPtr)
			{
				CompilerContext.MessageLog.Error(*LOCTEXT("NoVarriableTerm_Error", "ICE: no variable term found in @@").ToString(), Node);
				return;
			}
			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);
		}

		auto ValuePin = PureAssignmentNode->GetValuePin();
		ValidateAndRegisterNetIfLiteral(Context, ValuePin);
	}
Esempio n. 2
0
void FKCHandler_VariableSet::RegisterNets(FKismetFunctionContext& Context, UEdGraphNode* Node)
{
    if(UK2Node_Variable* SetterNode = Cast<UK2Node_Variable>(Node))
    {
        SetterNode->CheckForErrors(CompilerContext.GetSchema(), Context.MessageLog);

        if(FBlueprintEditorUtils::IsPropertyReadOnlyInCurrentBlueprint(Context.Blueprint, SetterNode->GetPropertyForVariable()))
        {
            CompilerContext.MessageLog.Warning(*LOCTEXT("BlueprintReadOnlyOrPrivate_Error", "The property is marked as BlueprintReadOnly or Private. It cannot be modifed in the blueprint. @@").ToString(), Node);
        }

        // Report an error that the local variable could not be found
        if(SetterNode->VariableReference.IsLocalScope() && SetterNode->GetPropertyForVariable() == NULL)
        {
            FFormatNamedArguments Args;
            Args.Add(TEXT("VariableName"), FText::FromName(SetterNode->VariableReference.GetMemberName()));

            if(SetterNode->VariableReference.GetMemberScopeName() != Context.Function->GetName())
            {
                Args.Add(TEXT("ScopeName"), FText::FromString(SetterNode->VariableReference.GetMemberScopeName()));
                CompilerContext.MessageLog.Warning(*FText::Format(LOCTEXT("LocalVariableNotFoundInScope_Error", "Unable to find local variable with name '{VariableName}' for @@, scope expected: @@, scope found: {ScopeName}"), Args).ToString(), Node, Node->GetGraph());
            }
            else
            {
                CompilerContext.MessageLog.Warning(*FText::Format(LOCTEXT("LocalVariableNotFound_Error", "Unable to find local variable with name '{VariableName}' for @@"), Args).ToString(), Node);
            }
        }
    }

    for (int32 PinIndex = 0; PinIndex < Node->Pins.Num(); ++PinIndex)
    {
        UEdGraphPin* Net = Node->Pins[PinIndex];
        if (!CompilerContext.GetSchema()->IsMetaPin(*Net) && (Net->Direction == EGPD_Input))
        {
            if (ValidateAndRegisterNetIfLiteral(Context, Net))
            {
                RegisterNet(Context, Net);
            }
        }
    }
}
	virtual void RegisterNets(FKismetFunctionContext& Context, UEdGraphNode* Node) override
	{
		UK2Node_VariableSetRef* VarRefNode = CastChecked<UK2Node_VariableSetRef>(Node);
		UEdGraphPin* ValuePin = VarRefNode->GetValuePin();
		ValidateAndRegisterNetIfLiteral(Context, ValuePin);
	}