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
35 changes: 13 additions & 22 deletions Source/Flow/Private/Nodes/Actor/FlowNode_OnNotifyFromActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ void UFlowNode_OnNotifyFromActor::ObserveActor(TWeakObjectPtr<AActor> Actor, TWe
RegisteredActors.Emplace(Actor, Component);
Component->OnNotifyFromComponent.AddUObject(this, &UFlowNode_OnNotifyFromActor::OnNotifyFromComponent);

if (bRetroactive && Component->GetRecentlySentNotifyTags().HasAnyExact(NotifyTags))
if (bRetroactive)
{
OnEventReceived();
const bool NotifyMatches = FlowTypes::HasMatchingTags(Component->GetRecentlySentNotifyTags(), NotifyTags, NotifyMatchType);
if (NotifyMatches)
{
OnEventReceived();
}
}
}
}
Expand All @@ -33,27 +37,14 @@ void UFlowNode_OnNotifyFromActor::ForgetActor(TWeakObjectPtr<AActor> Actor, TWea

void UFlowNode_OnNotifyFromActor::OnNotifyFromComponent(UFlowComponent* Component, const FGameplayTag& Tag)
{
bool IdentityMatches = false;

switch (IdentityMatchType)
{
case EFlowTagContainerMatchType::HasAny:
IdentityMatches = Component->IdentityTags.HasAny(IdentityTags);
break;
case EFlowTagContainerMatchType::HasAnyExact:
IdentityMatches = Component->IdentityTags.HasAnyExact(IdentityTags);
break;
case EFlowTagContainerMatchType::HasAll:
IdentityMatches = Component->IdentityTags.HasAll(IdentityTags);
break;
case EFlowTagContainerMatchType::HasAllExact:
IdentityMatches = Component->IdentityTags.HasAllExact(IdentityTags);
break;
}

if (IdentityMatches && (!NotifyTags.IsValid() || NotifyTags.HasTagExact(Tag)))
const bool IdentityMatches = FlowTypes::HasMatchingTags(Component->IdentityTags, IdentityTags, IdentityMatchType);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use of already existing utility function

if (IdentityMatches)
{
OnEventReceived();
const bool NotifyMatches = NotifyTags.IsValid() ? FlowTypes::HasMatchingTag(Tag, NotifyTags, NotifyMatchType) : true;
if (NotifyMatches)
{
OnEventReceived();
}
}
}

Expand Down
33 changes: 33 additions & 0 deletions Source/Flow/Public/FlowTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ enum class EFlowNetMode : uint8
SinglePlayerOnly UMETA(ToolTip = "Executed only in the single player, not available in multiplayer.")
};

UENUM(BlueprintType)
enum class EFlowTagMatchType : uint8
{
Has UMETA(ToolTip = "Check if container contains the tag."),
HasExact UMETA(ToolTip = "Check if container contains the tag, only allowing exact matches."),
};

UENUM(BlueprintType)
enum class EFlowTagContainerMatchType : uint8
{
Expand All @@ -88,6 +95,32 @@ enum class EFlowTagContainerMatchType : uint8

namespace FlowTypes
{
FORCEINLINE_DEBUGGABLE bool HasMatchingTag(const FGameplayTag& Tag, const FGameplayTagContainer& Container, const EFlowTagMatchType MatchType)
{
switch (MatchType)
{
case EFlowTagMatchType::Has:
return Tag.MatchesAny(Container);
case EFlowTagMatchType::HasExact:
return Tag.MatchesAnyExact(Container);
default:
return false;
}
}

FORCEINLINE_DEBUGGABLE bool HasMatchingTags(const FGameplayTagContainer& Container, const FGameplayTagContainer& OtherContainer, const EFlowTagMatchType MatchType)
{
switch (MatchType)
{
case EFlowTagMatchType::Has:
return Container.HasAny(OtherContainer);
case EFlowTagMatchType::HasExact:
return Container.HasAnyExact(OtherContainer);
default:
return false;
}
}

FORCEINLINE_DEBUGGABLE bool HasMatchingTags(const FGameplayTagContainer& Container, const FGameplayTagContainer& OtherContainer, const EFlowTagContainerMatchType MatchType)
{
switch (MatchType)
Expand Down
3 changes: 3 additions & 0 deletions Source/Flow/Public/Nodes/Actor/FlowNode_OnNotifyFromActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class FLOW_API UFlowNode_OnNotifyFromActor : public UFlowNode_ComponentObserver
UPROPERTY(EditAnywhere, Category = "Notify")
FGameplayTagContainer NotifyTags;

UPROPERTY(EditAnywhere, Category = "Notify")
EFlowTagMatchType NotifyMatchType = EFlowTagMatchType::HasExact;

/* If true, node will check given Notify Tag is present in the Recently Sent Notify Tags.
* This might be helpful in multiplayer, if client-side Flow Node started work after server sent the Notify. */
UPROPERTY(EditAnywhere, Category = "Notify")
Expand Down