Skip to content

add context effects execute condition #386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
#include <Kismet/GameplayStatics.h>
#include <NiagaraFunctionLibrary.h>

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
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down