2021-01-06 14:01:38 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "RigVMModel/RigVMFunctionLibrary.h"
|
|
|
|
|
|
|
|
|
|
URigVMFunctionLibrary::URigVMFunctionLibrary()
|
|
|
|
|
: URigVMGraph()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-14 15:00:40 -04:00
|
|
|
FString URigVMFunctionLibrary::GetNodePath() const
|
|
|
|
|
{
|
|
|
|
|
return FString::Printf(TEXT("FunctionLibrary::%s"), *Super::GetNodePath());
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-06 14:01:38 -04:00
|
|
|
TArray<URigVMLibraryNode*> URigVMFunctionLibrary::GetFunctions() const
|
|
|
|
|
{
|
|
|
|
|
TArray<URigVMLibraryNode*> Functions;
|
|
|
|
|
|
|
|
|
|
for (URigVMNode* Node : GetNodes())
|
|
|
|
|
{
|
|
|
|
|
// we only allow library nodes under a function library graph
|
|
|
|
|
URigVMLibraryNode* LibraryNode = CastChecked<URigVMLibraryNode>(Node);
|
|
|
|
|
Functions.Add(LibraryNode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Functions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
URigVMLibraryNode* URigVMFunctionLibrary::FindFunction(const FName& InFunctionName) const
|
|
|
|
|
{
|
2021-01-14 15:00:40 -04:00
|
|
|
FString FunctionNameStr = InFunctionName.ToString();
|
|
|
|
|
if (FunctionNameStr.StartsWith(TEXT("FunctionLibrary::|")))
|
|
|
|
|
{
|
|
|
|
|
FunctionNameStr.RightChopInline(18);
|
|
|
|
|
}
|
|
|
|
|
return Cast<URigVMLibraryNode>(FindNodeByName(*FunctionNameStr));
|
2021-01-06 14:01:38 -04:00
|
|
|
}
|
|
|
|
|
|
2021-01-19 13:37:12 -04:00
|
|
|
TArray< TSoftObjectPtr<URigVMFunctionReferenceNode> > URigVMFunctionLibrary::GetReferencesForFunction(const FName& InFunctionName)
|
|
|
|
|
{
|
|
|
|
|
TArray< TSoftObjectPtr<URigVMFunctionReferenceNode> > Result;
|
|
|
|
|
|
|
|
|
|
if (URigVMLibraryNode* Function = FindFunction(InFunctionName))
|
|
|
|
|
{
|
|
|
|
|
FRigVMFunctionReferenceArray* ReferencesEntry = FunctionReferences.Find(Function);
|
|
|
|
|
if (ReferencesEntry)
|
|
|
|
|
{
|
|
|
|
|
for (int32 ReferenceIndex = 0; ReferenceIndex < ReferencesEntry->Num(); ReferenceIndex++)
|
|
|
|
|
{
|
|
|
|
|
const TSoftObjectPtr<URigVMFunctionReferenceNode>& Reference = ReferencesEntry->operator [](ReferenceIndex);
|
|
|
|
|
Result.Add(TSoftObjectPtr<URigVMFunctionReferenceNode>(Reference.GetUniqueID()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TArray< FString > URigVMFunctionLibrary::GetReferencePathsForFunction(const FName& InFunctionName)
|
|
|
|
|
{
|
|
|
|
|
TArray< FString > Result;
|
|
|
|
|
|
|
|
|
|
if (URigVMLibraryNode* Function = FindFunction(InFunctionName))
|
|
|
|
|
{
|
|
|
|
|
FRigVMFunctionReferenceArray* ReferencesEntry = FunctionReferences.Find(Function);
|
|
|
|
|
if (ReferencesEntry)
|
|
|
|
|
{
|
|
|
|
|
for (int32 ReferenceIndex = 0; ReferenceIndex < ReferencesEntry->Num(); ReferenceIndex++)
|
|
|
|
|
{
|
|
|
|
|
const TSoftObjectPtr<URigVMFunctionReferenceNode>& Reference = ReferencesEntry->operator [](ReferenceIndex);
|
|
|
|
|
Result.Add(Reference.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Result;
|
|
|
|
|
}
|