// Copyright Epic Games, Inc. All Rights Reserved.
#include "K2Node_AsyncAction_ListenForGameplayMessages.h"
#include "BlueprintActionDatabaseRegistrar.h"
#include "BlueprintFunctionNodeSpawner.h"
#include "BlueprintNodeSpawner.h"
#include "Containers/EnumAsByte.h"
#include "Containers/UnrealString.h"
#include "Delegates/Delegate.h"
#include "EdGraph/EdGraphNode.h"
#include "EdGraph/EdGraphPin.h"
#include "EdGraph/EdGraphSchema.h"
#include "EdGraphSchema_K2.h"
#include "Engine/MemberReference.h"
#include "GameFramework/AsyncAction_ListenForGameplayMessage.h"
#include "HAL/Platform.h"
#include "Internationalization/Internationalization.h"
#include "Internationalization/Text.h"
#include "K2Node_AssignmentStatement.h"
#include "K2Node_CallFunction.h"
#include "K2Node_TemporaryVariable.h"
#include "KismetCompiler.h"
#include "Misc/AssertionMacros.h"
#include "Templates/Casts.h"
#include "Templates/SubclassOf.h"
#include "UObject/Class.h"
#include "UObject/Field.h"
#include "UObject/NameTypes.h"
#include "UObject/ObjectPtr.h"
#include "UObject/UnrealType.h"
#include "UObject/WeakObjectPtr.h"
#include "UObject/WeakObjectPtrTemplates.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(K2Node_AsyncAction_ListenForGameplayMessages)
class UEdGraph;
#define LOCTEXT_NAMESPACE "K2Node"
namespace UK2Node_AsyncAction_ListenForGameplayMessagesHelper
{
static FName ActualChannelPinName = "ActualChannel";
static FName PayloadPinName = "Payload";
static FName PayloadTypePinName = "PayloadType";
static FName DelegateProxyPinName = "ProxyObject";
};
void UK2Node_AsyncAction_ListenForGameplayMessages::PostReconstructNode()
{
Super::PostReconstructNode();
RefreshOutputPayloadType();
}
void UK2Node_AsyncAction_ListenForGameplayMessages::PinDefaultValueChanged(UEdGraphPin* ChangedPin)
{
if (ChangedPin == GetPayloadTypePin())
{
if (ChangedPin->LinkedTo.Num() == 0)
{
RefreshOutputPayloadType();
}
}
}
void UK2Node_AsyncAction_ListenForGameplayMessages::GetPinHoverText(const UEdGraphPin& Pin, FString& HoverTextOut) const
{
Super::GetPinHoverText(Pin, HoverTextOut);
if (Pin.PinName == UK2Node_AsyncAction_ListenForGameplayMessagesHelper::PayloadPinName)
{
HoverTextOut = HoverTextOut + LOCTEXT("PayloadOutTooltip", "\n\nThe message structure that we received").ToString();
}
}
void UK2Node_AsyncAction_ListenForGameplayMessages::GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const
{
struct GetMenuActions_Utils
{
static void SetNodeFunc(UEdGraphNode* NewNode, bool /*bIsTemplateNode*/, TWeakObjectPtr<UFunction> FunctionPtr)
{
UK2Node_AsyncAction_ListenForGameplayMessages* AsyncTaskNode = CastChecked<UK2Node_AsyncAction_ListenForGameplayMessages>(NewNode);
if (FunctionPtr.IsValid())
{
UFunction* Func = FunctionPtr.Get();
FObjectProperty* ReturnProp = CastFieldChecked<FObjectProperty>(Func->GetReturnProperty());
AsyncTaskNode->ProxyFactoryFunctionName = Func->GetFName();
AsyncTaskNode->ProxyFactoryClass = Func->GetOuterUClass();
AsyncTaskNode->ProxyClass = ReturnProp->PropertyClass;
}
}
};
UClass* NodeClass = GetClass();
ActionRegistrar.RegisterClassFactoryActions<UAsyncAction_ListenForGameplayMessage>(FBlueprintActionDatabaseRegistrar::FMakeFuncSpawnerDelegate::CreateLambda([NodeClass](const UFunction* FactoryFunc)->UBlueprintNodeSpawner*
{
UBlueprintNodeSpawner* NodeSpawner = UBlueprintFunctionNodeSpawner::Create(FactoryFunc);
check(NodeSpawner != nullptr);
NodeSpawner->NodeClass = NodeClass;
TWeakObjectPtr<UFunction> FunctionPtr = MakeWeakObjectPtr(const_cast<UFunction*>(FactoryFunc));
NodeSpawner->CustomizeNodeDelegate = UBlueprintNodeSpawner::FCustomizeNodeDelegate::CreateStatic(GetMenuActions_Utils::SetNodeFunc, FunctionPtr);
return NodeSpawner;
}) );
}
void UK2Node_AsyncAction_ListenForGameplayMessages::AllocateDefaultPins()
{
Super::AllocateDefaultPins();
// The output of the UAsyncAction_ListenForGameplayMessage delegates is a proxy object which is used in the follow up call of GetPayload when triggered
// This is only needed in the internals of this node so hide the pin from the editor.
UEdGraphPin* DelegateProxyPin = FindPin(UK2Node_AsyncAction_ListenForGameplayMessagesHelper::DelegateProxyPinName);
if (ensure(DelegateProxyPin))
{
DelegateProxyPin->bHidden = true;
}
CreatePin(EGPD_Output, UEdGraphSchema_K2::PC_Wildcard, UK2Node_AsyncAction_ListenForGameplayMessagesHelper::PayloadPinName);
}
bool UK2Node_AsyncAction_ListenForGameplayMessages::HandleDelegates(const TArray<FBaseAsyncTaskHelper::FOutputPinAndLocalVariable>& VariableOutputs, UEdGraphPin* ProxyObjectPin, UEdGraphPin*& InOutLastThenPin, UEdGraph* SourceGraph, FKismetCompilerContext& CompilerContext)
{
bool bIsErrorFree = true;
if (VariableOutputs.Num() != 3)
{
ensureMsgf(false, TEXT("UK2Node_AsyncAction_ListenForGameplayMessages::HandleDelegates - Variable output array not valid. Output delegates must only have the single proxy object output and than must have pin for payload."));
return false;
}
for (TFieldIterator<FMulticastDelegateProperty> PropertyIt(ProxyClass); PropertyIt && bIsErrorFree; ++PropertyIt)
{
UEdGraphPin* LastActivatedThenPin = nullptr;
bIsErrorFree &= FBaseAsyncTaskHelper::HandleDelegateImplementation(*PropertyIt, VariableOutputs, ProxyObjectPin, InOutLastThenPin, LastActivatedThenPin, this, SourceGraph, CompilerContext);
bIsErrorFree &= HandlePayloadImplementation(*PropertyIt, VariableOutputs[0], VariableOutputs[2], VariableOutputs[1], LastActivatedThenPin, SourceGraph, CompilerContext);
}
return bIsErrorFree;
}
bool UK2Node_AsyncAction_ListenForGameplayMessages::HandlePayloadImplementation(FMulticastDelegateProperty* CurrentProperty, const FBaseAsyncTaskHelper::FOutputPinAndLocalVariable& ProxyObjectVar, const FBaseAsyncTaskHelper::FOutputPinAndLocalVariable& PayloadVar, const FBaseAsyncTaskHelper::FOutputPinAndLocalVariable& ActualChannelVar, UEdGraphPin*& InOutLastActivatedThenPin, UEdGraph* SourceGraph, FKismetCompilerContext& CompilerContext)
{
bool bIsErrorFree = true;
const UEdGraphPin* PayloadPin = GetPayloadPin();
const UEdGraphSchema_K2* Schema = CompilerContext.GetSchema();
check(CurrentProperty && SourceGraph && Schema);
const FEdGraphPinType& PinType = PayloadPin->PinType;
if (PinType.PinCategory == UEdGraphSchema_K2::PC_Wildcard)
{
if (PayloadPin->LinkedTo.Num() == 0)
{
// If no payload type is specified and we're not trying to connect the output to anything ignore the rest of this step
return true;
}
else
{
return false;
}
}
UK2Node_TemporaryVariable* TempVarOutput = CompilerContext.SpawnInternalVariable(
this, PinType.PinCategory, PinType.PinSubCategory, PinType.PinSubCategoryObject.Get(), PinType.ContainerType, PinType.PinValueType);
UK2Node_CallFunction* const CallGetPayloadNode = CompilerContext.SpawnIntermediateNode<UK2Node_CallFunction>(this, SourceGraph);
CallGetPayloadNode->FunctionReference.SetExternalMember(TEXT("GetPayload"), CurrentProperty->GetOwnerClass());
CallGetPayloadNode->AllocateDefaultPins();
// Hook up the self connection
UEdGraphPin* GetPayloadCallSelfPin = Schema->FindSelfPin(*CallGetPayloadNode, EGPD_Input);
if (GetPayloadCallSelfPin)
{
bIsErrorFree &= Schema->TryCreateConnection(GetPayloadCallSelfPin, ProxyObjectVar.TempVar->GetVariablePin());
// Hook the activate node up in the exec chain
UEdGraphPin* GetPayloadExecPin = CallGetPayloadNode->FindPinChecked(UEdGraphSchema_K2::PN_Execute);
UEdGraphPin* GetPayloadThenPin = CallGetPayloadNode->FindPinChecked(UEdGraphSchema_K2::PN_Then);
UEdGraphPin* LastThenPin = nullptr;
UEdGraphPin* GetPayloadPin = CallGetPayloadNode->FindPinChecked(TEXT("OutPayload"));
bIsErrorFree &= Schema->TryCreateConnection(T
没有合适的资源?快使用搜索试试~ 我知道了~
GameplayMessageRouter游戏消息子系统插件UE5.1.1版本
共17个文件
cpp:5个
h:4个
pdb:2个
需积分: 0 0 下载量 110 浏览量
2023-06-08
09:17:17
上传
评论
收藏 20.97MB ZIP 举报
温馨提示
游戏消息子系统是我们用来在C++或蓝图中传递消息的插件,非常的好用,虽然目前还是测试版,但是已经可以用于正式项目了。 如何使用游戏消息子系统来解耦?https://blog.csdn.net/qq_30137245/article/details/130809120
资源推荐
资源详情
资源评论
收起资源包目录
GameplayMessageRouter.zip (17个子文件)
GameplayMessageRouter
Source
GameplayMessageRuntime
Private
GameFramework
GameplayMessageRuntime.cpp 154B
GameplayMessageSubsystem.cpp 6KB
AsyncAction_ListenForGameplayMessage.cpp 4KB
GameplayMessageRuntime.Build.cs 584B
Public
GameFramework
AsyncAction_ListenForGameplayMessage.h 3KB
GameplayMessageTypes2.h 2KB
GameplayMessageSubsystem.h 9KB
GameplayMessageNodes
Private
GameplayMessageNodesModule.cpp 153B
K2Node_AsyncAction_ListenForGameplayMessages.cpp 10KB
GameplayMessageNodes.Build.cs 655B
Public
K2Node_AsyncAction_ListenForGameplayMessages.h 2KB
Binaries
Win64
UnrealEditor.modules 190B
UnrealEditor-GameplayMessageNodes.pdb 46.13MB
UnrealEditor-GameplayMessageNodes.dll 115KB
UnrealEditor-GameplayMessageRuntime.pdb 49.49MB
UnrealEditor-GameplayMessageRuntime.dll 146KB
GameplayMessageRouter.uplugin 809B
共 17 条
- 1
资源评论
CloudHu1989
- 粉丝: 615
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 【unity开发】Unity文档的开发人员注释
- 微信小程序-周公解梦.zip
- ijkplayer ffmpeg6.1.1 编译好的so库 arm64
- 免费云注入软件,提供脱壳,云注入等服务,海口市奋斗科技有限公司旗下产业
- YOLOv5+Deepsort+python实现驾驶员分心驾驶行为(疲劳+危险行为)预警监测+源码+文档+视频演示(高分优秀项目
- 海口市奋斗智能科技有限公司旗下的免费影视软件
- 奋斗社区,各种编程大佬资源分享社区
- androidx.media3.exoplayer,libflac库
- java毕业设计 - 药源购物网站(ssm+Vue+说明文档+LW+PPT)
- VNC Viewer手机版远程桌面
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功