From f1e0c63e61352b46b83bdf45d69453a26dfb1f5d Mon Sep 17 00:00:00 2001 From: Michael Delva Date: Thu, 13 Feb 2025 16:20:57 +0100 Subject: [PATCH] Added delegate when the interaction options are updated --- .../Private/Interaction/GBFInteractableComponent.cpp | 2 ++ .../Public/Interaction/GBFInteractableComponent.h | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/Source/GameBaseFramework/Private/Interaction/GBFInteractableComponent.cpp b/Source/GameBaseFramework/Private/Interaction/GBFInteractableComponent.cpp index acd4790e..99f2ea0d 100644 --- a/Source/GameBaseFramework/Private/Interaction/GBFInteractableComponent.cpp +++ b/Source/GameBaseFramework/Private/Interaction/GBFInteractableComponent.cpp @@ -31,11 +31,13 @@ void UGBFInteractableComponent::UpdateInteractions( UGBFInteractionOptionsData * } InteractionOptionContainer.AddOptions( options_data->Options ); + OnInteractionsUpdatedDelegate.Broadcast(); } void UGBFInteractableComponent::RemoveInteractions() { InteractionOptionContainer.ResetOptions(); + OnInteractionsUpdatedDelegate.Broadcast(); } void UGBFInteractableComponent::OnInteractableActorEnteredRadius( AActor * actor ) diff --git a/Source/GameBaseFramework/Public/Interaction/GBFInteractableComponent.h b/Source/GameBaseFramework/Public/Interaction/GBFInteractableComponent.h index 72f76f89..6d66fbc7 100644 --- a/Source/GameBaseFramework/Public/Interaction/GBFInteractableComponent.h +++ b/Source/GameBaseFramework/Public/Interaction/GBFInteractableComponent.h @@ -18,11 +18,13 @@ class GAMEBASEFRAMEWORK_API UGBFInteractableComponent : public UActorComponent public: DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam( FGBFOnInteractableInteractionRadiusStateChangedDelegate, AActor *, Actor ); + DECLARE_DYNAMIC_MULTICAST_DELEGATE( FGBFOnInteractionsUpdatedDelegate ); UGBFInteractableComponent(); FGBFOnInteractableInteractionRadiusStateChangedDelegate & OnInteractableActorEnteredRadius(); FGBFOnInteractableInteractionRadiusStateChangedDelegate & OnInteractableLeftRadius(); + FGBFOnInteractionsUpdatedDelegate & OnInteractionsUpdated(); const FGBFInteractionOptionContainer & GetInteractableOptions() const; bool IsEnabled() const; @@ -66,6 +68,9 @@ class GAMEBASEFRAMEWORK_API UGBFInteractableComponent : public UActorComponent UPROPERTY( BlueprintAssignable, meta = ( AllowPrivateAccess = true ) ) FGBFOnInteractableInteractionRadiusStateChangedDelegate OnInteractableActorLeftRadiusDelegate; + UPROPERTY( BlueprintAssignable, meta = ( AllowPrivateAccess = true ) ) + FGBFOnInteractionsUpdatedDelegate OnInteractionsUpdatedDelegate; + UPROPERTY() TArray< TObjectPtr< AActor > > ActorsInInteractionRadius; }; @@ -95,6 +100,11 @@ FORCEINLINE UGBFInteractableComponent::FGBFOnInteractableInteractionRadiusStateC return OnInteractableActorLeftRadiusDelegate; } +FORCEINLINE UGBFInteractableComponent::FGBFOnInteractionsUpdatedDelegate & UGBFInteractableComponent::OnInteractionsUpdated() +{ + return OnInteractionsUpdatedDelegate; +} + FORCEINLINE bool UGBFInteractableComponent::HasInteractableActorsInRadius() const { return !ActorsInInteractionRadius.IsEmpty();