65 lines
1.7 KiB
C++
65 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "MCPHandler.h"
|
|
#include "MCPFetcher.h"
|
|
#include "MCPUtils.h"
|
|
#include "Animation/AnimBlueprint.h"
|
|
#include "AnimGraphNode_Base.h"
|
|
#include "AnimBlueprint_ListSyncGroups.generated.h"
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------------
|
|
|
|
UCLASS()
|
|
class UMCP_AnimBlueprint_ListSyncGroups : public UObject, public IMCPHandler
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
UPROPERTY(meta=(Description="Path to an Animation Blueprint, e.g. /Game/Foo/ABP_Character"))
|
|
FString Path;
|
|
|
|
virtual FString GetDescription() const override
|
|
{
|
|
return TEXT("List all sync group names used in an Animation Blueprint.");
|
|
}
|
|
|
|
virtual void Handle(const FJsonObject* Json, FStringBuilderBase& Result) override
|
|
{
|
|
MCPFetcher F(Result);
|
|
UAnimBlueprint* AnimBP = F.Walk(Path).Cast<UAnimBlueprint>();
|
|
if (!AnimBP) return;
|
|
|
|
// Walk all anim nodes to collect sync group names
|
|
TSet<FString> SyncGroupNames;
|
|
for (UAnimGraphNode_Base* AnimNode : MCPUtils::AllNodes<UAnimGraphNode_Base>(AnimBP))
|
|
{
|
|
for (TFieldIterator<FNameProperty> PropIt(AnimNode->GetClass()); PropIt; ++PropIt)
|
|
{
|
|
if (PropIt->GetName().Contains(TEXT("SyncGroup")) || PropIt->GetName().Contains(TEXT("GroupName")))
|
|
{
|
|
FName GroupValue = PropIt->GetPropertyValue_InContainer(AnimNode);
|
|
if (!GroupValue.IsNone())
|
|
{
|
|
SyncGroupNames.Add(GroupValue.ToString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (SyncGroupNames.Num() == 0)
|
|
{
|
|
Result.Append(TEXT("No sync groups found.\n"));
|
|
return;
|
|
}
|
|
|
|
for (const FString& Group : SyncGroupNames)
|
|
{
|
|
Result.Appendf(TEXT("%s\n"), *Group);
|
|
}
|
|
}
|
|
};
|