Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 39 additions & 39 deletions Source/Flow/Private/Nodes/Graph/FlowNode_SubGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,45 @@ void UFlowNode_SubGraph::FlushContent()
}
}

FFlowDataPinResult UFlowNode_SubGraph::TrySupplyDataPin(FName PinName) const
{
if (PinName == AssetParams_MemberName)
{
// Prevent infinite recursion by sourcing the AssetParams pin directly
// (otherwise, it would attempt to resolve it below and infinitely crash our stack.
// don't ask me how I know).
return Super::TrySupplyDataPin(PinName);
}

if (!IsInputConnected(PinName))
{
const bool bHasAssetParams = IsInputConnected(AssetParams_MemberName) || !AssetParams.IsNull();
if (bHasAssetParams)
{
// If not connected, we can source the value from the asset data params (if available)
TObjectPtr<UObject> Value = nullptr;
const EFlowDataPinResolveResult ResultEnum = Super::TryResolveDataPinValue<FFlowPinType_Object>(AssetParams_MemberName, Value);
if (FlowPinType::IsSuccess(ResultEnum) && IsValid(Value))
{
if (const IFlowDataPinValueSupplierInterface* SupplierInterface = Cast<IFlowDataPinValueSupplierInterface>(Value))
{
return SupplierInterface->TrySupplyDataPin(PinName);
}
else
{
LogError(FString::Printf(TEXT("Could not cast object %s to IFlowDataPinValueSupplierInterface! This is unexpected."), *Value->GetName()));

return FFlowDataPinResult(EFlowDataPinResolveResult::FailedWithError);
}
}
}
}

// Prefer the standard lookup if the pin is connected
// (or if there is no FlowAssetParams to ask)
return Super::TrySupplyDataPin(PinName);
}

void UFlowNode_SubGraph::ExecuteInput(const FName& PinName)
{
// Since this node implements IFlowPreloadableInterface,
Expand Down Expand Up @@ -238,45 +277,6 @@ void UFlowNode_SubGraph::AutoGenerateDataPins(FFlowDataPinValueOwner& ValueOwner
}
}

FFlowDataPinResult UFlowNode_SubGraph::TrySupplyDataPin(FName PinName) const
{
if (PinName == AssetParams_MemberName)
{
// Prevent infinite recursion by sourcing the AssetParams pin directly
// (otherwise, it would attempt to resolve it below and infinitely crash our stack.
// don't ask me how I know).
return Super::TrySupplyDataPin(PinName);
}

if (!IsInputConnected(PinName))
{
const bool bHasAssetParams = IsInputConnected(AssetParams_MemberName) || !AssetParams.IsNull();
if (bHasAssetParams)
{
// If not connected, we can source the value from the asset data params (if available)
TObjectPtr<UObject> Value = nullptr;
const EFlowDataPinResolveResult ResultEnum = Super::TryResolveDataPinValue<FFlowPinType_Object>(AssetParams_MemberName, Value);
if (FlowPinType::IsSuccess(ResultEnum) && IsValid(Value))
{
if (const IFlowDataPinValueSupplierInterface* SupplierInterface = Cast<IFlowDataPinValueSupplierInterface>(Value))
{
return SupplierInterface->TrySupplyDataPin(PinName);
}
else
{
LogError(FString::Printf(TEXT("Could not cast object %s to IFlowDataPinValueSupplierInterface! This is unexpected."), *Value->GetName()));

return FFlowDataPinResult(EFlowDataPinResolveResult::FailedWithError);
}
}
}
}

// Prefer the standard lookup if the pin is connected
// (or if there is no FlowAssetParams to ask)
return Super::TrySupplyDataPin(PinName);
}

void UFlowNode_SubGraph::PostLoad()
{
Super::PostLoad();
Expand Down
8 changes: 4 additions & 4 deletions Source/Flow/Public/Nodes/Graph/FlowNode_SubGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class FLOW_API UFlowNode_SubGraph
virtual void FlushContent() override;
// --

// IFlowDataPinValueSupplierInterface
virtual FFlowDataPinResult TrySupplyDataPin(FName PinName) const override;
// --

virtual void ExecuteInput(const FName& PinName) override;
virtual void Cleanup() override;

Expand Down Expand Up @@ -90,10 +94,6 @@ class FLOW_API UFlowNode_SubGraph
virtual void AutoGenerateDataPins(FFlowDataPinValueOwner& ValueOwner, FFlowAutoDataPinsWorkingData& InOutWorkingData) override;
// --

// IFlowDataPinValueSupplierInterface
virtual FFlowDataPinResult TrySupplyDataPin(FName PinName) const override;
// --

// UObject
virtual void PostLoad() override;
virtual void PreEditChange(FProperty* PropertyAboutToChange) override;
Expand Down