From bb1b2c45f382edde5a7b7bdb207074473edd1a0d Mon Sep 17 00:00:00 2001 From: Frederic Deiber Date: Wed, 21 May 2025 18:18:29 +0200 Subject: [PATCH] add context effects execute condition --- .../GBFAnimNotify_ContextEffects.cpp | 15 +++++++++++++++ .../ContextEffects/GBFAnimNotify_ContextEffects.h | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFAnimNotify_ContextEffects.cpp b/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFAnimNotify_ContextEffects.cpp index 09160ff3..3f542f06 100644 --- a/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFAnimNotify_ContextEffects.cpp +++ b/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFAnimNotify_ContextEffects.cpp @@ -10,6 +10,11 @@ #include #include +bool UGBFContextEffectsExecuteCondition::CanExecuteContextEffects_Implementation( USkeletalMeshComponent * mesh_comp, AActor * owning_actor, UAnimSequenceBase * animation ) const +{ + return false; +} + FString UGBFAnimNotify_ContextEffects::GetNotifyName_Implementation() const { // If the Effect Tag is valid, pass the string name to the notify name @@ -37,6 +42,16 @@ void UGBFAnimNotify_ContextEffects::Notify( USkeletalMeshComponent * mesh_comp, return; } + // Can Execute ContextEffects ? + if ( ContextEffectExecuteCondition != nullptr ) + { + const auto * execute_condition = NewObject< UGBFContextEffectsExecuteCondition >( this, ContextEffectExecuteCondition ); + if ( execute_condition == nullptr || !execute_condition->CanExecuteContextEffects( mesh_comp, owning_actor, animation ) ) + { + return; + } + } + // Prepare Trace Data bool hit_success = false; FHitResult hit_result; diff --git a/Source/GameBaseFramework/Public/Feedback/ContextEffects/GBFAnimNotify_ContextEffects.h b/Source/GameBaseFramework/Public/Feedback/ContextEffects/GBFAnimNotify_ContextEffects.h index affdd65b..87a9ebf4 100644 --- a/Source/GameBaseFramework/Public/Feedback/ContextEffects/GBFAnimNotify_ContextEffects.h +++ b/Source/GameBaseFramework/Public/Feedback/ContextEffects/GBFAnimNotify_ContextEffects.h @@ -82,6 +82,16 @@ struct GAMEBASEFRAMEWORK_API FGBFContextEffectAnimNotifyPreviewSettings FGameplayTagContainer PreviewContexts; }; +UCLASS( Abstract, Blueprintable ) +class UGBFContextEffectsExecuteCondition : public UObject +{ + GENERATED_BODY() + +public: + UFUNCTION( BlueprintNativeEvent ) + bool CanExecuteContextEffects( USkeletalMeshComponent * mesh_comp, AActor * owning_actor, UAnimSequenceBase * animation ) const; +}; + UCLASS( const, hidecategories = Object, CollapseCategories, Config = Game, meta = ( DisplayName = "Play Context Effects" ) ) class GAMEBASEFRAMEWORK_API UGBFAnimNotify_ContextEffects : public UAnimNotify { @@ -140,6 +150,10 @@ class GAMEBASEFRAMEWORK_API UGBFAnimNotify_ContextEffects : public UAnimNotify UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "AnimNotify", meta = ( ExposeOnSpawn = true, EditCondition = "bPerformTrace" ) ) FGBFContextEffectAnimNotifyTraceSettings TraceProperties; + // Execute Condition, will execute if nullptr + UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "AnimNotify", meta = ( ExposeOnSpawn = true ) ) + TSubclassOf< UGBFContextEffectsExecuteCondition > ContextEffectExecuteCondition; + #if WITH_EDITORONLY_DATA UPROPERTY( Config, EditAnywhere, Category = "PreviewProperties" ) uint32 bPreviewInEditor : 1;