ue-mcp 0.4.8 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tools/blueprint.js
CHANGED
|
@@ -34,7 +34,7 @@ export const blueprintTool = categoryTool("blueprint", "Blueprint reading, autho
|
|
|
34
34
|
- create_function: Create function. Params: assetPath, functionName
|
|
35
35
|
- delete_function: Delete function. Params: assetPath, functionName
|
|
36
36
|
- rename_function: Rename function. Params: assetPath, oldName, newName
|
|
37
|
-
- add_node: Add graph node (
|
|
37
|
+
- add_node: Add graph node (any UEdGraphNode subclass). Aliases: CallFunction, Event, CustomEvent, GetVar, SetVar, Branch. nodeParams: functionName+targetClass for CallFunction, eventName+eventClass? for Event, variableName for GetVar/SetVar. Params: assetPath, graphName?, nodeClass, nodeParams?
|
|
38
38
|
- delete_node: Delete node. Params: assetPath, graphName, nodeName
|
|
39
39
|
- set_node_property: Set node pin default or struct property (supports dot paths like "Node.IKBone.BoneName"). Params: assetPath, graphName, nodeName, propertyName, value
|
|
40
40
|
- connect_pins: Wire nodes. Params: sourceNode, sourcePin, targetNode, targetPin, assetPath, graphName?
|
package/package.json
CHANGED
|
@@ -41,6 +41,22 @@
|
|
|
41
41
|
#include "Kismet/KismetStringLibrary.h"
|
|
42
42
|
#include "Kismet/KismetArrayLibrary.h"
|
|
43
43
|
|
|
44
|
+
// Helper: find a UClass by short name (e.g. "AnimInstance" finds UAnimInstance)
|
|
45
|
+
static UClass* FindClassByShortName(const FString& ClassName)
|
|
46
|
+
{
|
|
47
|
+
UClass* PrefixedMatch = nullptr;
|
|
48
|
+
for (TObjectIterator<UClass> It; It; ++It)
|
|
49
|
+
{
|
|
50
|
+
const FString& Name = It->GetName();
|
|
51
|
+
if (Name == ClassName) return *It;
|
|
52
|
+
if (!PrefixedMatch && (Name == TEXT("U") + ClassName || Name == TEXT("A") + ClassName))
|
|
53
|
+
{
|
|
54
|
+
PrefixedMatch = *It;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return PrefixedMatch;
|
|
58
|
+
}
|
|
59
|
+
|
|
44
60
|
void FBlueprintHandlers::RegisterHandlers(FMCPHandlerRegistry& Registry)
|
|
45
61
|
{
|
|
46
62
|
Registry.RegisterHandler(TEXT("create_blueprint"), &CreateBlueprint);
|
|
@@ -996,8 +1012,12 @@ TSharedPtr<FJsonValue> FBlueprintHandlers::AddNode(const TSharedPtr<FJsonObject>
|
|
|
996
1012
|
|
|
997
1013
|
// Resolve short aliases to full class names
|
|
998
1014
|
FString ResolvedClass = NodeClass;
|
|
999
|
-
if (NodeClass == TEXT("CallFunction"))
|
|
1000
|
-
else if (NodeClass == TEXT("Event"))
|
|
1015
|
+
if (NodeClass == TEXT("CallFunction")) ResolvedClass = TEXT("K2Node_CallFunction");
|
|
1016
|
+
else if (NodeClass == TEXT("Event")) ResolvedClass = TEXT("K2Node_Event");
|
|
1017
|
+
else if (NodeClass == TEXT("GetVar")) ResolvedClass = TEXT("K2Node_VariableGet");
|
|
1018
|
+
else if (NodeClass == TEXT("SetVar")) ResolvedClass = TEXT("K2Node_VariableSet");
|
|
1019
|
+
else if (NodeClass == TEXT("Branch")) ResolvedClass = TEXT("K2Node_IfThenElse");
|
|
1020
|
+
else if (NodeClass == TEXT("CustomEvent")) ResolvedClass = TEXT("K2Node_CustomEvent");
|
|
1001
1021
|
|
|
1002
1022
|
// Find the UEdGraphNode subclass by name (works for K2, AnimGraph, and any other graph node types)
|
|
1003
1023
|
UClass* NodeUClass = nullptr;
|
|
@@ -1026,34 +1046,34 @@ TSharedPtr<FJsonValue> FBlueprintHandlers::AddNode(const TSharedPtr<FJsonObject>
|
|
|
1026
1046
|
return MakeShared<FJsonValueObject>(Result);
|
|
1027
1047
|
}
|
|
1028
1048
|
|
|
1029
|
-
// Special-case initialization for known types
|
|
1049
|
+
// Special-case initialization for known types (must happen BEFORE AllocateDefaultPins)
|
|
1030
1050
|
if (UK2Node_CallFunction* CallNode = Cast<UK2Node_CallFunction>(NewNode))
|
|
1031
1051
|
{
|
|
1032
1052
|
if (NodeParams)
|
|
1033
1053
|
{
|
|
1034
1054
|
FString FunctionName;
|
|
1035
|
-
if ((*NodeParams)->TryGetStringField(TEXT("functionName"), FunctionName))
|
|
1055
|
+
if (!(*NodeParams)->TryGetStringField(TEXT("functionName"), FunctionName))
|
|
1056
|
+
(*NodeParams)->TryGetStringField(TEXT("memberName"), FunctionName);
|
|
1057
|
+
|
|
1058
|
+
if (!FunctionName.IsEmpty())
|
|
1036
1059
|
{
|
|
1037
1060
|
FString TargetClassName;
|
|
1038
|
-
if ((*NodeParams)->TryGetStringField(TEXT("targetClass"), TargetClassName))
|
|
1061
|
+
if (!(*NodeParams)->TryGetStringField(TEXT("targetClass"), TargetClassName))
|
|
1062
|
+
(*NodeParams)->TryGetStringField(TEXT("memberParent"), TargetClassName);
|
|
1063
|
+
|
|
1064
|
+
UClass* TargetClass = nullptr;
|
|
1065
|
+
if (!TargetClassName.IsEmpty())
|
|
1039
1066
|
{
|
|
1040
|
-
|
|
1041
|
-
if (!TargetClass)
|
|
1042
|
-
{
|
|
1043
|
-
TargetClass = FindObject<UClass>(nullptr, *(TEXT("U") + TargetClassName));
|
|
1044
|
-
}
|
|
1045
|
-
if (TargetClass)
|
|
1046
|
-
{
|
|
1047
|
-
UFunction* Func = TargetClass->FindFunctionByName(FName(*FunctionName));
|
|
1048
|
-
if (Func)
|
|
1049
|
-
{
|
|
1050
|
-
CallNode->SetFromFunction(Func);
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1067
|
+
TargetClass = FindClassByShortName(TargetClassName);
|
|
1053
1068
|
}
|
|
1054
|
-
|
|
1069
|
+
if (!TargetClass)
|
|
1055
1070
|
{
|
|
1056
|
-
|
|
1071
|
+
TargetClass = Blueprint->ParentClass;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
if (TargetClass)
|
|
1075
|
+
{
|
|
1076
|
+
UFunction* Func = TargetClass->FindFunctionByName(FName(*FunctionName));
|
|
1057
1077
|
if (Func)
|
|
1058
1078
|
{
|
|
1059
1079
|
CallNode->SetFromFunction(Func);
|
|
@@ -1067,9 +1087,58 @@ TSharedPtr<FJsonValue> FBlueprintHandlers::AddNode(const TSharedPtr<FJsonObject>
|
|
|
1067
1087
|
if (NodeParams)
|
|
1068
1088
|
{
|
|
1069
1089
|
FString EventName;
|
|
1070
|
-
if ((*NodeParams)->TryGetStringField(TEXT("eventName"), EventName))
|
|
1090
|
+
if (!(*NodeParams)->TryGetStringField(TEXT("eventName"), EventName))
|
|
1091
|
+
(*NodeParams)->TryGetStringField(TEXT("memberName"), EventName);
|
|
1092
|
+
|
|
1093
|
+
if (!EventName.IsEmpty())
|
|
1094
|
+
{
|
|
1095
|
+
FString EventClassName;
|
|
1096
|
+
if (!(*NodeParams)->TryGetStringField(TEXT("eventClass"), EventClassName))
|
|
1097
|
+
(*NodeParams)->TryGetStringField(TEXT("memberParent"), EventClassName);
|
|
1098
|
+
|
|
1099
|
+
if (!EventClassName.IsEmpty())
|
|
1100
|
+
{
|
|
1101
|
+
// Engine event override — bind via EventReference
|
|
1102
|
+
UClass* EventClass = FindClassByShortName(EventClassName);
|
|
1103
|
+
if (!EventClass) EventClass = Blueprint->ParentClass;
|
|
1104
|
+
|
|
1105
|
+
if (EventClass)
|
|
1106
|
+
{
|
|
1107
|
+
UFunction* EventFunc = EventClass->FindFunctionByName(FName(*EventName));
|
|
1108
|
+
if (EventFunc)
|
|
1109
|
+
{
|
|
1110
|
+
bool bIsSelf = Blueprint->ParentClass && Blueprint->ParentClass->IsChildOf(EventClass);
|
|
1111
|
+
EventNode->EventReference.SetFromField<UFunction>(EventFunc, bIsSelf);
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
else
|
|
1116
|
+
{
|
|
1117
|
+
// Custom event — just set the name
|
|
1118
|
+
EventNode->CustomFunctionName = FName(*EventName);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
else if (UK2Node_VariableGet* GetNode = Cast<UK2Node_VariableGet>(NewNode))
|
|
1124
|
+
{
|
|
1125
|
+
if (NodeParams)
|
|
1126
|
+
{
|
|
1127
|
+
FString VarName;
|
|
1128
|
+
if ((*NodeParams)->TryGetStringField(TEXT("variableName"), VarName))
|
|
1129
|
+
{
|
|
1130
|
+
GetNode->VariableReference.SetSelfMember(FName(*VarName));
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
else if (UK2Node_VariableSet* SetNode = Cast<UK2Node_VariableSet>(NewNode))
|
|
1135
|
+
{
|
|
1136
|
+
if (NodeParams)
|
|
1137
|
+
{
|
|
1138
|
+
FString VarName;
|
|
1139
|
+
if ((*NodeParams)->TryGetStringField(TEXT("variableName"), VarName))
|
|
1071
1140
|
{
|
|
1072
|
-
|
|
1141
|
+
SetNode->VariableReference.SetSelfMember(FName(*VarName));
|
|
1073
1142
|
}
|
|
1074
1143
|
}
|
|
1075
1144
|
}
|