You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb sara.schvartzman #jira UE-140239 #preflight https://horde.devtools.epicgames.com/job/6203d14b724404041858cd83 #lockdown juan.canada #ROBOMERGE-AUTHOR: helge.mathee #ROBOMERGE-SOURCE: CL 18934230 in //UE5/Release-5.0/... via CL 18934300 via CL 18934322 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v916-18915374) [CL 18934323 by helge mathee in ue5-main branch]
162 lines
4.1 KiB
C++
162 lines
4.1 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "RigVMModel/RigVMFunctionLibrary.h"
|
|
|
|
#include "RigVMModel/RigVMController.h"
|
|
|
|
URigVMFunctionLibrary::URigVMFunctionLibrary()
|
|
: URigVMGraph()
|
|
{
|
|
|
|
}
|
|
|
|
FString URigVMFunctionLibrary::GetNodePath() const
|
|
{
|
|
return FString::Printf(TEXT("FunctionLibrary::%s"), *Super::GetNodePath());
|
|
}
|
|
|
|
URigVMFunctionLibrary* URigVMFunctionLibrary::GetDefaultFunctionLibrary() const
|
|
{
|
|
if(URigVMFunctionLibrary* DefaultFunctionLibrary = Super::GetDefaultFunctionLibrary())
|
|
{
|
|
return DefaultFunctionLibrary;
|
|
}
|
|
return (URigVMFunctionLibrary*)this;
|
|
}
|
|
|
|
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
|
|
{
|
|
FString FunctionNameStr = InFunctionName.ToString();
|
|
if (FunctionNameStr.StartsWith(TEXT("FunctionLibrary::|")))
|
|
{
|
|
FunctionNameStr.RightChopInline(18);
|
|
}
|
|
return Cast<URigVMLibraryNode>(FindNodeByName(*FunctionNameStr));
|
|
}
|
|
|
|
URigVMLibraryNode* URigVMFunctionLibrary::FindFunctionForNode(URigVMNode* InNode) const
|
|
{
|
|
if(InNode == nullptr)
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
UObject* Subject = InNode;
|
|
while (Subject->GetOuter() != this)
|
|
{
|
|
Subject = Subject->GetOuter();
|
|
if(Subject == nullptr)
|
|
{
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
return Cast<URigVMLibraryNode>(Subject);
|
|
}
|
|
|
|
URigVMBuildData* URigVMFunctionLibrary::GetBuildData() const
|
|
{
|
|
return URigVMController::GetBuildData();
|
|
}
|
|
|
|
TArray< TSoftObjectPtr<URigVMFunctionReferenceNode> > URigVMFunctionLibrary::GetReferencesForFunction(const FName& InFunctionName)
|
|
{
|
|
TArray< TSoftObjectPtr<URigVMFunctionReferenceNode> > Result;
|
|
|
|
ForEachReferenceSoftPtr(InFunctionName, [&Result](TSoftObjectPtr<URigVMFunctionReferenceNode> Reference)
|
|
{
|
|
Result.Add(TSoftObjectPtr<URigVMFunctionReferenceNode>(Reference.GetUniqueID()));
|
|
});
|
|
|
|
return Result;
|
|
}
|
|
|
|
TArray< FString > URigVMFunctionLibrary::GetReferencePathsForFunction(const FName& InFunctionName)
|
|
{
|
|
TArray< FString > Result;
|
|
|
|
ForEachReferenceSoftPtr(InFunctionName, [&Result](TSoftObjectPtr<URigVMFunctionReferenceNode> Reference)
|
|
{
|
|
Result.Add(Reference.ToString());
|
|
});
|
|
|
|
return Result;
|
|
}
|
|
|
|
void URigVMFunctionLibrary::ForEachReference(const FName& InFunctionName,
|
|
TFunction<void(URigVMFunctionReferenceNode*)> PerReferenceFunction) const
|
|
{
|
|
if (URigVMLibraryNode* Function = FindFunction(InFunctionName))
|
|
{
|
|
if(const URigVMBuildData* BuildData = GetBuildData())
|
|
{
|
|
BuildData->ForEachFunctionReference(Function, PerReferenceFunction);
|
|
}
|
|
}
|
|
}
|
|
|
|
void URigVMFunctionLibrary::ForEachReferenceSoftPtr(const FName& InFunctionName,
|
|
TFunction<void(TSoftObjectPtr<URigVMFunctionReferenceNode>)> PerReferenceFunction) const
|
|
{
|
|
if (URigVMLibraryNode* Function = FindFunction(InFunctionName))
|
|
{
|
|
if(const URigVMBuildData* BuildData = GetBuildData())
|
|
{
|
|
BuildData->ForEachFunctionReferenceSoftPtr(Function, PerReferenceFunction);
|
|
}
|
|
}
|
|
}
|
|
|
|
URigVMLibraryNode* URigVMFunctionLibrary::FindPreviouslyLocalizedFunction(URigVMLibraryNode* InFunctionToLocalize)
|
|
{
|
|
if(InFunctionToLocalize == nullptr)
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
const FString PathName = InFunctionToLocalize->GetPathName();
|
|
|
|
if(!LocalizedFunctions.Contains((PathName)))
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
URigVMLibraryNode* LocalizedFunction = LocalizedFunctions.FindChecked(PathName);
|
|
|
|
// once we found the function - let's make sure it's notation is right
|
|
if(LocalizedFunction->GetPins().Num() != InFunctionToLocalize->GetPins().Num())
|
|
{
|
|
return nullptr;
|
|
}
|
|
for(int32 PinIndex=0; PinIndex < InFunctionToLocalize->GetPins().Num(); PinIndex++)
|
|
{
|
|
URigVMPin* PinA = InFunctionToLocalize->GetPins()[PinIndex];
|
|
URigVMPin* PinB = LocalizedFunction->GetPins()[PinIndex];
|
|
|
|
if((PinA->GetFName() != PinB->GetFName()) ||
|
|
(PinA->GetCPPType() != PinB->GetCPPType()) ||
|
|
(PinA->GetCPPTypeObject() != PinB->GetCPPTypeObject()) ||
|
|
(PinA->IsArray() != PinB->IsArray()))
|
|
{
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
return LocalizedFunction;
|
|
}
|
|
|