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
6 changes: 5 additions & 1 deletion Flow.uplugin
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"FileVersion" : 3,
"Version" : 2.2,
"FriendlyName" : "Flow",
Expand Down Expand Up @@ -42,6 +42,10 @@
{
"Name": "EngineAssetDefinitions",
"Enabled": true
},
{
"Name": "GameplayAbilities",
"Enabled": true
}
]
}
1 change: 1 addition & 0 deletions Source/Flow/Flow.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public Flow(ReadOnlyTargetRules target) : base(target)
"CoreUObject",
"DeveloperSettings",
"Engine",
"GameplayAbilities", // for FGameplayTagRequirements
"GameplayTags",
"MovieScene",
"MovieSceneTracks",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// Copyright https://github.com/MothCocoon/FlowGraph/graphs/contributors

#include "AddOns/FlowNodeAddOn_PredicateRequireGameplayTags.h"
#include "FlowLogChannels.h"
#include "Nodes/FlowNode.h"
#include "Logging/LogMacros.h"

#include UE_INLINE_GENERATED_CPP_BY_NAME(FlowNodeAddOn_PredicateRequireGameplayTags)

UFlowNodeAddOn_PredicateRequireGameplayTags::UFlowNodeAddOn_PredicateRequireGameplayTags()
: Super()
{
#if WITH_EDITOR
NodeDisplayStyle = FlowNodeStyle::AddOn_Predicate;
Category = TEXT("DataPins");
#endif
}

bool UFlowNodeAddOn_PredicateRequireGameplayTags::EvaluatePredicate_Implementation() const
{
if (Requirements.IsEmpty())
{
// And Empty Requirements results in a "true" result
return true;
}

FGameplayTagContainer TagsValue;

// Sourcing the tags from the data pin
if (!TryGetTagsToCheckFromDataPin(TagsValue))
{
return false;
}

// Execute the Tags vs the Requirements
const bool bResult = Requirements.RequirementsMet(TagsValue);
return bResult;
}

#if WITH_EDITOR
void UFlowNodeAddOn_PredicateRequireGameplayTags::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);

UpdateNodeConfigText();
}

void UFlowNodeAddOn_PredicateRequireGameplayTags::OnEditorPinConnectionsChanged(const TArray<FFlowPinConnectionChange>& Changes)
{
Super::OnEditorPinConnectionsChanged(Changes);

UpdateNodeConfigText();
}
#endif

bool UFlowNodeAddOn_PredicateRequireGameplayTags::TryGetTagsToCheckFromDataPin(FGameplayTagContainer& TagsToCheckValue) const
{
static const FName TagsName = GET_MEMBER_NAME_CHECKED(UFlowNodeAddOn_PredicateRequireGameplayTags, Tags);

const EFlowDataPinResolveResult ResultEnum = TryResolveDataPinValue<FFlowPinType_GameplayTagContainer>(TagsName, TagsToCheckValue);

if (FlowPinType::IsSuccess(ResultEnum))
{
return true;
}
else
{
UE_LOG(LogFlow, Error, TEXT("Cannot EvaluatePredicate on a data pin value we cannot resolve: %s"), *UEnum::GetDisplayValueAsText(ResultEnum).ToString());

return false;
}
}

void UFlowNodeAddOn_PredicateRequireGameplayTags::UpdateNodeConfigText_Implementation()
{
#if WITH_EDITOR
const FName TagsName = GET_MEMBER_NAME_CHECKED(UFlowNodeAddOn_PredicateRequireGameplayTags, Tags);
FTextBuilder TextBuilder;
if (Requirements.IsEmpty())
{
const FName RequirementsName = GET_MEMBER_NAME_CHECKED(UFlowNodeAddOn_PredicateRequireGameplayTags, Requirements);
TextBuilder.AppendLine(FString::Printf(TEXT("<not configured - Must have configured %s>"), *RequirementsName.ToString()));
}
else if (Tags.IsEmpty() && !GetFlowNode()->IsInputConnected(TagsName))
{
TextBuilder.AppendLine(FString::Printf(TEXT("<not configured - %s must have a default value or a connected pin>"), *TagsName.ToString()));
}
else
{
TextBuilder.AppendLine(Requirements.ToString());
}

SetNodeConfigText(TextBuilder.ToText());
#endif // WITH_EDITOR
}
15 changes: 12 additions & 3 deletions Source/Flow/Private/Nodes/Developer/FlowNode_Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,23 @@ void UFlowNode_Log::PostEditChangeChainProperty(FPropertyChangedChainEvent& Prop
Super::PostEditChangeChainProperty(PropertyChainEvent);
}

void UFlowNode_Log::OnEditorPinConnectionsChanged(const TArray<FFlowPinConnectionChange>& Changes)
{
Super::OnEditorPinConnectionsChanged(Changes);

UpdateNodeConfigText();
}

void UFlowNode_Log::UpdateNodeConfigText_Implementation()
{
constexpr bool bErrorIfInputPinNotFound = false;
const bool bIsInputConnected = IsInputConnected(GET_MEMBER_NAME_CHECKED(ThisClass, Message), bErrorIfInputPinNotFound);
constexpr bool bErrorIfInputPinNotFound = true;

FConnectedPin ConnectedPin;
const bool bIsInputConnected = FindFirstInputPinConnection(GET_MEMBER_NAME_CHECKED(ThisClass, Message), bErrorIfInputPinNotFound, ConnectedPin);

if (bIsInputConnected)
{
SetNodeConfigText(FText());
SetNodeConfigText(FText::Format(LOCTEXT("LogFromPin", "Message from: {0}"), { FText::FromString(ConnectedPin.PinName.ToString()) }));
}
else
{
Expand Down
Loading