Files
integration/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Blueprint_ListInterfaces.h

59 lines
1.4 KiB
C++

#pragma once
#include "CoreMinimal.h"
#include "MCPServer.h"
#include "MCPHandler.h"
#include "MCPFetcher.h"
#include "MCPUtils.h"
#include "Engine/Blueprint.h"
#include "Blueprint_ListInterfaces.generated.h"
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
UCLASS()
class UMCP_Blueprint_ListInterfaces : public UObject, public IMCPHandler
{
GENERATED_BODY()
public:
UPROPERTY(meta=(Description="Path to a blueprint, e.g. /Game/Foo/MyBlueprint"))
FString Path;
virtual FString GetDescription() const override
{
return TEXT("List all Blueprint Interfaces implemented by a Blueprint, "
"including their function graphs.");
}
virtual void Handle() override
{
MCPFetcher F;
F.Walk(Path);
if (!F.Ok()) return;
UBlueprint* BP = F.Cast<UBlueprint>();
if (!BP) return;
bool bAny = false;
for (const FBPInterfaceDescription& IfaceDesc : BP->ImplementedInterfaces)
{
if (!IfaceDesc.Interface) continue;
bAny = true;
UMCPServer::Printf(TEXT("Interface: %s\n"), *MCPUtils::FormatName(IfaceDesc.Interface));
for (const UEdGraph* Graph : IfaceDesc.Graphs)
{
if (!Graph) continue;
UMCPServer::Printf(TEXT(" %s\n"), *MCPUtils::FormatName(Graph));
}
}
if (!bAny)
{
UMCPServer::Print(TEXT("No interfaces implemented.\n"));
}
}
};