53 lines
2.1 KiB
C++
53 lines
2.1 KiB
C++
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
|
|
|
|
|
#include "GGA_K2Node_ContextPayload.h"
|
|
#include "EdGraphSchema_K2.h"
|
|
#include "BlueprintNodeSpawner.h"
|
|
#include "BlueprintActionDatabaseRegistrar.h"
|
|
#include "Utilities/GGA_GameplayEffectFunctionLibrary.h"
|
|
|
|
void UGGA_K2Node_ContextPayload::GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const
|
|
{
|
|
Super::GetMenuActions(ActionRegistrar);
|
|
UClass* Action = GetClass();
|
|
if (ActionRegistrar.IsOpenForRegistration(Action))
|
|
{
|
|
auto CustomizeLambda = [](UEdGraphNode* NewNode, bool bIsTemplateNode, const FName FunctionName)
|
|
{
|
|
UGGA_K2Node_ContextPayload* Node = CastChecked<UGGA_K2Node_ContextPayload>(NewNode);
|
|
UFunction* Function = UGGA_GameplayEffectFunctionLibrary::StaticClass()->FindFunctionByName(FunctionName);
|
|
check(Function);
|
|
Node->SetFromFunction(Function);
|
|
};
|
|
|
|
UBlueprintNodeSpawner* SetNodeSpawner = UBlueprintNodeSpawner::Create(GetClass());
|
|
check(SetNodeSpawner != nullptr);
|
|
SetNodeSpawner->CustomizeNodeDelegate = UBlueprintNodeSpawner::FCustomizeNodeDelegate::CreateStatic(
|
|
CustomizeLambda, GET_FUNCTION_NAME_CHECKED(UGGA_GameplayEffectFunctionLibrary, SetContextPayload));
|
|
ActionRegistrar.AddBlueprintAction(Action, SetNodeSpawner);
|
|
|
|
// UBlueprintNodeSpawner* GetNodeSpawner = UBlueprintNodeSpawner::Create(GetClass());
|
|
// check(GetNodeSpawner != nullptr);
|
|
// GetNodeSpawner->CustomizeNodeDelegate = UBlueprintNodeSpawner::FCustomizeNodeDelegate::CreateStatic(
|
|
// CustomizeLambda, GET_FUNCTION_NAME_CHECKED(UGGA_GameplayEffectFunctionLibrary, GetContextPayload));
|
|
// ActionRegistrar.AddBlueprintAction(Action, GetNodeSpawner);
|
|
}
|
|
}
|
|
|
|
bool UGGA_K2Node_ContextPayload::IsConnectionDisallowed(const UEdGraphPin* MyPin, const UEdGraphPin* OtherPin, FString& OutReason) const
|
|
{
|
|
const UEdGraphPin* ValuePin = FindPinChecked(FName(TEXT("Value")));
|
|
|
|
if (MyPin == ValuePin && MyPin->PinType.PinCategory == UEdGraphSchema_K2::PC_Wildcard)
|
|
{
|
|
if (OtherPin->PinType.PinCategory != UEdGraphSchema_K2::PC_Struct)
|
|
{
|
|
OutReason = TEXT("Value must be a struct.");
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|