diff --git a/Source/Flow/Private/Nodes/Actor/FlowNode_OnNotifyFromActor.cpp b/Source/Flow/Private/Nodes/Actor/FlowNode_OnNotifyFromActor.cpp index 467ada146..a0af6972b 100644 --- a/Source/Flow/Private/Nodes/Actor/FlowNode_OnNotifyFromActor.cpp +++ b/Source/Flow/Private/Nodes/Actor/FlowNode_OnNotifyFromActor.cpp @@ -19,9 +19,13 @@ void UFlowNode_OnNotifyFromActor::ObserveActor(TWeakObjectPtr 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(); + } } } } @@ -33,27 +37,14 @@ void UFlowNode_OnNotifyFromActor::ForgetActor(TWeakObjectPtr 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); + if (IdentityMatches) { - OnEventReceived(); + const bool NotifyMatches = NotifyTags.IsValid() ? FlowTypes::HasMatchingTag(Tag, NotifyTags, NotifyMatchType) : true; + if (NotifyMatches) + { + OnEventReceived(); + } } } diff --git a/Source/Flow/Public/FlowTypes.h b/Source/Flow/Public/FlowTypes.h index 9b51d6c56..a5dec432f 100644 --- a/Source/Flow/Public/FlowTypes.h +++ b/Source/Flow/Public/FlowTypes.h @@ -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 { @@ -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) diff --git a/Source/Flow/Public/Nodes/Actor/FlowNode_OnNotifyFromActor.h b/Source/Flow/Public/Nodes/Actor/FlowNode_OnNotifyFromActor.h index e71609e35..3306f1c0a 100644 --- a/Source/Flow/Public/Nodes/Actor/FlowNode_OnNotifyFromActor.h +++ b/Source/Flow/Public/Nodes/Actor/FlowNode_OnNotifyFromActor.h @@ -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")