From f255fe81ea66c233ffeb75432f5cfa31b2a41986 Mon Sep 17 00:00:00 2001 From: jyelon Date: Sat, 14 Mar 2026 00:02:00 -0400 Subject: [PATCH] Convert handlers to MCPFetcher --- .../Handlers/AnimBlueprint_Create.h | 10 +++++----- .../Handlers/AnimBlueprint_ListSlotNames.h | 10 +++++----- .../AnimBlueprint_SetBlendSpaceSamples.h | 8 ++++---- .../BlueprintMCP/Handlers/BlendSpace_Create.h | 10 +++++----- .../Handlers/Blueprint_AddComponent.h | 10 +++++----- .../Handlers/Blueprint_AddFunctionParameter.h | 10 +++++----- .../Handlers/Blueprint_AddInterface.h | 9 +++++---- .../Handlers/Blueprint_AddVariable.h | 8 ++++---- .../Blueprint_ChangeFunctionParameterType.h | 10 +++++----- .../BlueprintMCP/Handlers/Blueprint_Diff.h | 18 +++++++++--------- .../Handlers/Blueprint_RefreshAllNodes.h | 10 +++++----- .../Blueprint_RemoveFunctionParameter.h | 9 ++++----- .../Handlers/Blueprint_RemoveInterface.h | 8 ++++---- .../BlueprintMCP/Handlers/Blueprint_Reparent.h | 6 +++--- .../Handlers/StateMachine_AddState.h | 12 ++++++------ .../Handlers/StateMachine_AddTransition.h | 10 +++++----- .../Handlers/StateMachine_SetAnimation.h | 11 +++++------ .../Handlers/StateMachine_SetBlendSpace.h | 17 ++++++++--------- .../Handlers/StateMachine_SetTransitionRule.h | 10 +++++----- .../BlueprintMCP/Private/MCPNotifier.cpp | 3 +++ 20 files changed, 100 insertions(+), 99 deletions(-) diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/AnimBlueprint_Create.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/AnimBlueprint_Create.h index 58ab3c4e..5a28aee9 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/AnimBlueprint_Create.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/AnimBlueprint_Create.h @@ -3,7 +3,7 @@ #include "CoreMinimal.h" #include "MCPServer.h" #include "MCPHandler.h" -#include "MCPAssets.h" +#include "MCPFetcher.h" #include "MCPUtils.h" #include "MCPPackageMaker.h" #include "Animation/AnimBlueprint.h" @@ -27,7 +27,7 @@ public: UPROPERTY(meta=(Description="Full asset path for the new Animation Blueprint (e.g. '/Game/AnimBP/ABP_Character')")) FString AssetPath; - UPROPERTY(meta=(Description="Name or path of the skeleton asset to use")) + UPROPERTY(meta=(Description="Skeleton asset package path")) FString Skeleton; UPROPERTY(meta=(Optional, Description="Parent class name (default: AnimInstance)")) @@ -44,9 +44,9 @@ public: if (!Maker.Ok()) return; // Resolve skeleton - MCPAssets SkeletonAssets; - if (!SkeletonAssets.Exact(Skeleton).ENone().ETwo().Load()) return; - USkeleton* SkeletonObj = SkeletonAssets.Object(); + MCPFetcher SkeletonFetcher; + USkeleton* SkeletonObj = SkeletonFetcher.Asset(Skeleton).Cast(); + if (!SkeletonObj) return; // Resolve parent class (default: UAnimInstance) UClass* ParentClassObj = UAnimInstance::StaticClass(); diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/AnimBlueprint_ListSlotNames.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/AnimBlueprint_ListSlotNames.h index 0cd8fc91..8c910093 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/AnimBlueprint_ListSlotNames.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/AnimBlueprint_ListSlotNames.h @@ -3,7 +3,7 @@ #include "CoreMinimal.h" #include "MCPServer.h" #include "MCPHandler.h" -#include "MCPAssets.h" +#include "MCPFetcher.h" #include "MCPUtils.h" #include "Animation/AnimBlueprint.h" #include "AnimGraphNode_Base.h" @@ -20,7 +20,7 @@ class UMCP_AnimBlueprint_ListSlotNames : public UObject, public IMCPHandler GENERATED_BODY() public: - UPROPERTY(meta=(Description="Animation Blueprint name or package path")) + UPROPERTY(meta=(Description="Animation Blueprint package path")) FString Blueprint; virtual FString GetDescription() const override @@ -30,9 +30,9 @@ public: virtual void Handle() override { - MCPAssets Assets; - if (!Assets.Exact(Blueprint).ENone().ETwo().Load()) return; - UAnimBlueprint* AnimBP = Assets.Object(); + MCPFetcher F; + UAnimBlueprint* AnimBP = F.Asset(Blueprint).Cast(); + if (!AnimBP) return; // Walk all anim nodes to collect slot names TSet SlotNames; diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/AnimBlueprint_SetBlendSpaceSamples.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/AnimBlueprint_SetBlendSpaceSamples.h index 57724411..d91ecd11 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/AnimBlueprint_SetBlendSpaceSamples.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/AnimBlueprint_SetBlendSpaceSamples.h @@ -36,7 +36,7 @@ class UMCP_AnimBlueprint_SetBlendSpaceSamples : public UObject, public IMCPHandl GENERATED_BODY() public: - UPROPERTY(meta=(Description="Blend Space asset name or package path")) + UPROPERTY(meta=(Description="Blend Space package path")) FString BlendSpace; UPROPERTY(meta=(Optional, Description="Display name for the X axis")) @@ -69,9 +69,9 @@ public: virtual void Handle() override { // Load the blend space - MCPAssets Assets; - if (!Assets.Exact(BlendSpace).ENone().ETwo().Load()) return; - UBlendSpace* BS = Assets.Object(); + MCPFetcher F; + UBlendSpace* BS = F.Asset(BlendSpace).Cast(); + if (!BS) return; // Set axis parameters const FBlendParameter& ParamX = BS->GetBlendParameter(0); diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/BlendSpace_Create.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/BlendSpace_Create.h index 6d7759aa..35b8f4eb 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/BlendSpace_Create.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/BlendSpace_Create.h @@ -3,7 +3,7 @@ #include "CoreMinimal.h" #include "MCPServer.h" #include "MCPHandler.h" -#include "MCPAssets.h" +#include "MCPFetcher.h" #include "MCPUtils.h" #include "MCPPackageMaker.h" #include "Animation/Skeleton.h" @@ -24,7 +24,7 @@ public: UPROPERTY(meta=(Description="Full asset path for the new Blend Space (e.g. '/Game/BlendSpaces/BS_Locomotion')")) FString AssetPath; - UPROPERTY(meta=(Description="Name or path of the skeleton asset to use")) + UPROPERTY(meta=(Description="Skeleton asset package path")) FString Skeleton; virtual FString GetDescription() const override @@ -38,9 +38,9 @@ public: if (!Maker.Ok()) return; // Resolve skeleton. - MCPAssets SkeletonAssets; - if (!SkeletonAssets.Exact(Skeleton).ENone().ETwo().Load()) return; - USkeleton* SkeletonObj = SkeletonAssets.Object(); + MCPFetcher SkeletonFetcher; + USkeleton* SkeletonObj = SkeletonFetcher.Asset(Skeleton).Cast(); + if (!SkeletonObj) return; // Create the package and Blend Space. if (!Maker.Make()) return; diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_AddComponent.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_AddComponent.h index 1ae4f21f..aed86b71 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_AddComponent.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_AddComponent.h @@ -2,7 +2,7 @@ #include "CoreMinimal.h" #include "MCPHandler.h" -#include "MCPAssets.h" +#include "MCPFetcher.h" #include "MCPUtils.h" #include "MCPServer.h" #include "Engine/Blueprint.h" @@ -22,7 +22,7 @@ class UMCP_Blueprint_AddComponent : public UObject, public IMCPHandler GENERATED_BODY() public: - UPROPERTY(meta=(Description="Blueprint name or package path")) + UPROPERTY(meta=(Description="Blueprint package path")) FString Blueprint; UPROPERTY(meta=(Description="Component class name (e.g. StaticMeshComponent, SceneComponent)")) @@ -42,9 +42,9 @@ public: virtual void Handle() override { - MCPAssets Assets; - if (!Assets.Exact(Blueprint).ENone().ETwo().Load()) return; - UBlueprint* BP = Assets.Object(); + MCPFetcher F; + UBlueprint* BP = F.Asset(Blueprint).Cast(); + if (!BP) return; USimpleConstructionScript* SCS = BP->SimpleConstructionScript; if (!SCS) diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_AddFunctionParameter.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_AddFunctionParameter.h index a7dd4521..2e95dca7 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_AddFunctionParameter.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_AddFunctionParameter.h @@ -2,7 +2,7 @@ #include "CoreMinimal.h" #include "MCPHandler.h" -#include "MCPAssets.h" +#include "MCPFetcher.h" #include "MCPUtils.h" #include "MCPServer.h" #include "Engine/Blueprint.h" @@ -25,7 +25,7 @@ class UMCP_Blueprint_AddFunctionParameter : public UObject, public IMCPHandler GENERATED_BODY() public: - UPROPERTY(meta=(Description="Blueprint name or package path")) + UPROPERTY(meta=(Description="Blueprint package path")) FString Blueprint; UPROPERTY(meta=(Description="Name of the function, custom event, or event dispatcher")) @@ -44,9 +44,9 @@ public: virtual void Handle() override { - MCPAssets Assets; - if (!Assets.Exact(Blueprint).ENone().ETwo().Load()) return; - UBlueprint* BP = Assets.Object(); + MCPFetcher F; + UBlueprint* BP = F.Asset(Blueprint).Cast(); + if (!BP) return; // Resolve param type FEdGraphPinType PinType; diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_AddInterface.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_AddInterface.h index 28405196..a8130255 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_AddInterface.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_AddInterface.h @@ -3,6 +3,7 @@ #include "CoreMinimal.h" #include "MCPHandler.h" #include "MCPAssets.h" +#include "MCPFetcher.h" #include "MCPUtils.h" #include "MCPServer.h" #include "Engine/Blueprint.h" @@ -21,7 +22,7 @@ class UMCP_Blueprint_AddInterface : public UObject, public IMCPHandler GENERATED_BODY() public: - UPROPERTY(meta=(Description="Blueprint name or package path")) + UPROPERTY(meta=(Description="Blueprint package path")) FString Blueprint; UPROPERTY(meta=(Description="Interface name (e.g. 'BPI_MyInterface') or native UInterface class name")) @@ -35,9 +36,9 @@ public: virtual void Handle() override { - MCPAssets Assets; - if (!Assets.Exact(Blueprint).ENone().ETwo().Load()) return; - UBlueprint* BP = Assets.Object(); + MCPFetcher F; + UBlueprint* BP = F.Asset(Blueprint).Cast(); + if (!BP) return; // Resolve the interface class UClass* InterfaceClass = FindInterfaceClass(InterfaceName); diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_AddVariable.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_AddVariable.h index a6c1d6e8..082da1c1 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_AddVariable.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_AddVariable.h @@ -2,7 +2,7 @@ #include "CoreMinimal.h" #include "MCPHandler.h" -#include "MCPAssets.h" +#include "MCPFetcher.h" #include "MCPUtils.h" #include "MCPServer.h" #include "Engine/Blueprint.h" @@ -45,9 +45,9 @@ public: virtual void Handle() override { - MCPAssets Assets; - if (!Assets.Exact(Blueprint).ENone().ETwo().Load()) return; - UBlueprint* BP = Assets.Object(); + MCPFetcher F; + UBlueprint* BP = F.Asset(Blueprint).Cast(); + if (!BP) return; // Check for duplicate variable name FName VarFName(*VariableName); diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_ChangeFunctionParameterType.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_ChangeFunctionParameterType.h index 637952fb..0ea3c3ae 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_ChangeFunctionParameterType.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_ChangeFunctionParameterType.h @@ -2,7 +2,7 @@ #include "CoreMinimal.h" #include "MCPHandler.h" -#include "MCPAssets.h" +#include "MCPFetcher.h" #include "MCPUtils.h" #include "MCPServer.h" #include "Engine/Blueprint.h" @@ -25,7 +25,7 @@ class UMCP_Blueprint_ChangeFunctionParameterType : public UObject, public IMCPHa GENERATED_BODY() public: - UPROPERTY(meta=(Description="Blueprint name or package path")) + UPROPERTY(meta=(Description="Blueprint package path")) FString Blueprint; UPROPERTY(meta=(Description="Name of the function or custom event")) @@ -47,9 +47,9 @@ public: virtual void Handle() override { - MCPAssets Assets; - if (!Assets.Exact(Blueprint).ENone().ETwo().Load()) return; - UBlueprint* BP = Assets.Object(); + MCPFetcher F; + UBlueprint* BP = F.Asset(Blueprint).Cast(); + if (!BP) return; // Resolve the new type using the shared resolver (supports primitives, structs, enums, and object references) FEdGraphPinType NewPinType; diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_Diff.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_Diff.h index 8ac8a448..d503e9f1 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_Diff.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_Diff.h @@ -3,7 +3,7 @@ #include "CoreMinimal.h" #include "MCPServer.h" #include "MCPHandler.h" -#include "MCPAssets.h" +#include "MCPFetcher.h" #include "MCPUtils.h" #include "Engine/Blueprint.h" #include "EdGraph/EdGraph.h" @@ -22,10 +22,10 @@ class UMCP_Blueprint_Diff : public UObject, public IMCPHandler GENERATED_BODY() public: - UPROPERTY(meta=(Description="First blueprint name or package path")) + UPROPERTY(meta=(Description="First blueprint package path")) FString BlueprintA; - UPROPERTY(meta=(Description="Second blueprint name or package path")) + UPROPERTY(meta=(Description="Second blueprint package path")) FString BlueprintB; UPROPERTY(meta=(Optional, Description="Filter to a specific graph name")) @@ -41,13 +41,13 @@ public: virtual void Handle() override { // Load both blueprints - MCPAssets AssetsA; - if (!AssetsA.Exact(BlueprintA).ENone().ETwo().Load()) return; - UBlueprint* BPA = AssetsA.Object(); + MCPFetcher FA; + UBlueprint* BPA = FA.Asset(BlueprintA).Cast(); + if (!BPA) return; - MCPAssets AssetsB; - if (!AssetsB.Exact(BlueprintB).ENone().ETwo().Load()) return; - UBlueprint* BPB = AssetsB.Object(); + MCPFetcher FB; + UBlueprint* BPB = FB.Asset(BlueprintB).Cast(); + if (!BPB) return; // Gather graphs, optionally filtering by name auto GatherGraphs = [this](UBlueprint* BP) -> TArray diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_RefreshAllNodes.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_RefreshAllNodes.h index 3e67c265..111baff4 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_RefreshAllNodes.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_RefreshAllNodes.h @@ -3,7 +3,7 @@ #include "CoreMinimal.h" #include "MCPServer.h" #include "MCPHandler.h" -#include "MCPAssets.h" +#include "MCPFetcher.h" #include "MCPUtils.h" #include "Engine/Blueprint.h" #include "EdGraph/EdGraph.h" @@ -23,7 +23,7 @@ class UMCP_Blueprint_RefreshAllNodes : public UObject, public IMCPHandler GENERATED_BODY() public: - UPROPERTY(meta=(Description="Blueprint name or package path")) + UPROPERTY(meta=(Description="Blueprint package path")) FString Blueprint; virtual FString GetDescription() const override @@ -35,9 +35,9 @@ public: virtual void Handle() override { // Load Blueprint - MCPAssets Assets; - if (!Assets.Exact(Blueprint).ENone().ETwo().Load()) return; - UBlueprint* BP = Assets.Object(); + MCPFetcher F; + UBlueprint* BP = F.Asset(Blueprint).Cast(); + if (!BP) return; int32 GraphCount = MCPUtils::AllGraphs(BP).Num(); int32 NodeCount = MCPUtils::AllNodes(BP).Num(); diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_RemoveFunctionParameter.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_RemoveFunctionParameter.h index 62a171eb..c3d586d7 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_RemoveFunctionParameter.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_RemoveFunctionParameter.h @@ -4,7 +4,6 @@ #include "MCPServer.h" #include "MCPHandler.h" #include "MCPFetcher.h" -#include "MCPAssets.h" #include "MCPUtils.h" #include "K2Node_FunctionEntry.h" #include "K2Node_CustomEvent.h" @@ -23,7 +22,7 @@ class UMCP_Blueprint_RemoveFunctionParameter : public UObject, public IMCPHandle GENERATED_BODY() public: - UPROPERTY(meta=(Description="Blueprint name or package path")) + UPROPERTY(meta=(Description="Blueprint package path")) FString Blueprint; UPROPERTY(meta=(Description="Name of the function or custom event")) @@ -39,9 +38,9 @@ public: virtual void Handle() override { - MCPAssets Assets; - if (!Assets.Exact(Blueprint).ENone().ETwo().Load()) return; - UBlueprint* BP = Assets.Object(); + MCPFetcher F; + UBlueprint* BP = F.Asset(Blueprint).Cast(); + if (!BP) return; // Find the entry node (function entry or custom event) UK2Node_EditablePinBase* EntryNode = nullptr; diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_RemoveInterface.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_RemoveInterface.h index 5fcef439..1142003e 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_RemoveInterface.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_RemoveInterface.h @@ -2,7 +2,7 @@ #include "CoreMinimal.h" #include "MCPHandler.h" -#include "MCPAssets.h" +#include "MCPFetcher.h" #include "MCPUtils.h" #include "MCPServer.h" #include "Engine/Blueprint.h" @@ -37,9 +37,9 @@ public: virtual void Handle() override { - MCPAssets Assets; - if (!Assets.Exact(Blueprint).ENone().ETwo().Load()) return; - UBlueprint* BP = Assets.Object(); + MCPFetcher F; + UBlueprint* BP = F.Asset(Blueprint).Cast(); + if (!BP) return; // Find the interface by name UClass* FoundInterface = nullptr; diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_Reparent.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_Reparent.h index 5468f6a3..071c352e 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_Reparent.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_Reparent.h @@ -36,9 +36,9 @@ public: virtual void Handle() override { // Load Blueprint - MCPAssets Assets; - if (!Assets.Exact(Blueprint).ENone().ETwo().Load()) return; - UBlueprint* BP = Assets.Object(); + MCPFetcher F; + UBlueprint* BP = F.Asset(Blueprint).Cast(); + if (!BP) return; FString OldParentName = BP->ParentClass ? MCPUtils::FormatName(BP->ParentClass) : TEXT("None"); diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_AddState.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_AddState.h index 57122881..88a662b7 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_AddState.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_AddState.h @@ -3,7 +3,6 @@ #include "CoreMinimal.h" #include "MCPServer.h" #include "MCPHandler.h" -#include "MCPAssets.h" #include "MCPFetcher.h" #include "MCPUtils.h" #include "EdGraph/EdGraph.h" @@ -26,7 +25,7 @@ class UMCP_StateMachine_AddState : public UObject, public IMCPHandler GENERATED_BODY() public: - UPROPERTY(meta=(Description="Animation Blueprint name or package path")) + UPROPERTY(meta=(Description="Animation Blueprint package path")) FString Blueprint; UPROPERTY(meta=(Description="State machine graph name")) @@ -41,7 +40,7 @@ public: UPROPERTY(meta=(Optional, Description="Y position of the new state node")) int32 PosY = 0; - UPROPERTY(meta=(Optional, Description="Animation asset name to assign to the state")) + UPROPERTY(meta=(Optional, Description="Animation asset package path to assign to the state")) FString AnimationAsset; virtual FString GetDescription() const override @@ -94,14 +93,15 @@ public: // Optionally set animation asset if (!AnimationAsset.IsEmpty() && NewState->GetBoundGraph()) { - MCPAssets AnimAssets; - if (!AnimAssets.Exact(AnimationAsset).ENone().ETwo().Load()) return; + MCPFetcher F2; + UAnimSequence* AnimSeq = F2.Asset(AnimationAsset).Cast(); + if (!AnimSeq) return; UAnimGraphNode_SequencePlayer* SeqNode = NewObject(NewState->GetBoundGraph()); SeqNode->CreateNewGuid(); SeqNode->PostPlacedNewNode(); SeqNode->AllocateDefaultPins(); - SeqNode->SetAnimationAsset(AnimAssets.Object()); + SeqNode->SetAnimationAsset(AnimSeq); SeqNode->NodePosX = 0; SeqNode->NodePosY = 0; NewState->GetBoundGraph()->AddNode(SeqNode, false, false); diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_AddTransition.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_AddTransition.h index b609bb14..e171c711 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_AddTransition.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_AddTransition.h @@ -3,7 +3,7 @@ #include "CoreMinimal.h" #include "MCPServer.h" #include "MCPHandler.h" -#include "MCPAssets.h" +#include "MCPFetcher.h" #include "MCPUtils.h" #include "Kismet2/KismetEditorUtilities.h" #include "Animation/AnimBlueprint.h" @@ -23,7 +23,7 @@ class UMCP_StateMachine_AddTransition : public UObject, public IMCPHandler GENERATED_BODY() public: - UPROPERTY(meta=(Description="Animation Blueprint name or package path")) + UPROPERTY(meta=(Description="Animation Blueprint package path")) FString Blueprint; UPROPERTY(meta=(Description="State machine graph name")) @@ -51,9 +51,9 @@ public: virtual void Handle() override { - MCPAssets Assets; - if (!Assets.Exact(Blueprint).ENone().ETwo().Load()) return; - UAnimBlueprint* AnimBP = Assets.Object(); + MCPFetcher F; + UAnimBlueprint* AnimBP = F.Asset(Blueprint).Cast(); + if (!AnimBP) return; UAnimationStateMachineGraph* SMGraph = MCPUtils::FindStateMachineGraph(AnimBP, Graph); if (!SMGraph) diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_SetAnimation.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_SetAnimation.h index bd80bfdc..c5659202 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_SetAnimation.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_SetAnimation.h @@ -3,7 +3,6 @@ #include "CoreMinimal.h" #include "MCPServer.h" #include "MCPHandler.h" -#include "MCPAssets.h" #include "MCPFetcher.h" #include "MCPUtils.h" #include "EdGraph/EdGraph.h" @@ -27,7 +26,7 @@ class UMCP_StateMachine_SetAnimation : public UObject, public IMCPHandler GENERATED_BODY() public: - UPROPERTY(meta=(Description="Animation Blueprint name or package path")) + UPROPERTY(meta=(Description="Animation Blueprint package path")) FString Blueprint; UPROPERTY(meta=(Description="State machine graph name")) @@ -36,7 +35,7 @@ public: UPROPERTY(meta=(Description="Name of the state to modify")) FString StateName; - UPROPERTY(meta=(Description="Animation asset name to assign")) + UPROPERTY(meta=(Description="Animation asset package path to assign")) FString AnimationAsset; virtual FString GetDescription() const override @@ -71,9 +70,9 @@ public: } // Find the animation asset - MCPAssets AnimAssets; - if (!AnimAssets.Exact(AnimationAsset).ENone().ETwo().Load()) return; - UAnimSequence* AnimSeq = AnimAssets.Object(); + MCPFetcher F2; + UAnimSequence* AnimSeq = F2.Asset(AnimationAsset).Cast(); + if (!AnimSeq) return; // Find existing SequencePlayer or create one UAnimGraphNode_SequencePlayer* SeqNode = nullptr; diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_SetBlendSpace.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_SetBlendSpace.h index 524e4bfd..fcadc5c4 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_SetBlendSpace.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_SetBlendSpace.h @@ -3,7 +3,6 @@ #include "CoreMinimal.h" #include "MCPServer.h" #include "MCPHandler.h" -#include "MCPAssets.h" #include "MCPFetcher.h" #include "MCPUtils.h" #include "EdGraph/EdGraph.h" @@ -30,7 +29,7 @@ class UMCP_StateMachine_SetBlendSpace : public UObject, public IMCPHandler GENERATED_BODY() public: - UPROPERTY(meta=(Description="Animation Blueprint name or package path")) + UPROPERTY(meta=(Description="Animation Blueprint package path")) FString Blueprint; UPROPERTY(meta=(Description="State machine graph name")) @@ -39,7 +38,7 @@ public: UPROPERTY(meta=(Description="Name of the state to modify")) FString StateName; - UPROPERTY(meta=(Description="Blend Space asset name or path")) + UPROPERTY(meta=(Description="Blend Space asset package path")) FString BlendSpace; UPROPERTY(meta=(Optional, Description="Blueprint variable name to wire to the X axis input")) @@ -57,9 +56,9 @@ public: virtual void Handle() override { // Load the anim blueprint - MCPAssets Assets; - if (!Assets.Exact(Blueprint).ENone().ETwo().Load()) return; - UAnimBlueprint* AnimBP = Assets.Object(); + MCPFetcher F; + UAnimBlueprint* AnimBP = F.Asset(Blueprint).Cast(); + if (!AnimBP) return; // Find the state machine graph and state UAnimationStateMachineGraph* SMGraph = MCPUtils::FindStateMachineGraph(AnimBP, Graph); @@ -72,9 +71,9 @@ public: if (!InnerGraph) { UMCPServer::Printf(TEXT("ERROR: State '%s' has no bound graph\n"), *StateName); return; } // Load the blend space asset - MCPAssets BlendSpaceAssets; - if (!BlendSpaceAssets.Exact(BlendSpace).ENone().ETwo().Load()) return; - UBlendSpace* BlendSpaceAsset = BlendSpaceAssets.Object(); + MCPFetcher F2; + UBlendSpace* BlendSpaceAsset = F2.Asset(BlendSpace).Cast(); + if (!BlendSpaceAsset) return; // Find existing BlendSpacePlayer or create one UAnimGraphNode_BlendSpacePlayer* BSNode = nullptr; diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_SetTransitionRule.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_SetTransitionRule.h index 6fb5cf55..b0b68825 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_SetTransitionRule.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/StateMachine_SetTransitionRule.h @@ -3,7 +3,7 @@ #include "CoreMinimal.h" #include "MCPServer.h" #include "MCPHandler.h" -#include "MCPAssets.h" +#include "MCPFetcher.h" #include "MCPUtils.h" #include "Kismet2/KismetEditorUtilities.h" #include "Animation/AnimBlueprint.h" @@ -22,7 +22,7 @@ class UMCP_StateMachine_SetTransitionRule : public UObject, public IMCPHandler GENERATED_BODY() public: - UPROPERTY(meta=(Description="Animation Blueprint name or package path")) + UPROPERTY(meta=(Description="Animation Blueprint package path")) FString Blueprint; UPROPERTY(meta=(Description="State machine graph name")) @@ -56,9 +56,9 @@ public: virtual void Handle() override { - MCPAssets Assets; - if (!Assets.Exact(Blueprint).ENone().ETwo().Load()) return; - UAnimBlueprint* AnimBP = Assets.Object(); + MCPFetcher F; + UAnimBlueprint* AnimBP = F.Asset(Blueprint).Cast(); + if (!AnimBP) return; UAnimationStateMachineGraph* SMGraph = MCPUtils::FindStateMachineGraph(AnimBP, Graph); if (!SMGraph) diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Private/MCPNotifier.cpp b/Plugins/BlueprintMCP/Source/BlueprintMCP/Private/MCPNotifier.cpp index a35abe90..03849ae9 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Private/MCPNotifier.cpp +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Private/MCPNotifier.cpp @@ -50,6 +50,9 @@ void MCPNotifier::SendNotifications() for (UBlueprint *Blueprint : Blueprints) FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(Blueprint); + // FBlueprintEditorUtils::RefreshAllNodes(BP); + // FKismetEditorUtilities::CompileBlueprint(BP); + if (GEditor) GEditor->RedrawAllViewports();