From 686294ab4107e02e9bbd3c1e1f976f7d54ccb3af Mon Sep 17 00:00:00 2001 From: baz Date: Thu, 18 Jul 2024 01:39:27 +0100 Subject: [PATCH] Add parameters to Event Delegates --- Source/vampires/EXPComponent.cpp | 7 +++++-- Source/vampires/EXPComponent.h | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Source/vampires/EXPComponent.cpp b/Source/vampires/EXPComponent.cpp index 670f703..d43bd5f 100644 --- a/Source/vampires/EXPComponent.cpp +++ b/Source/vampires/EXPComponent.cpp @@ -17,14 +17,15 @@ void UEXPComponent::IncrementEXP(int value) { // TODO: I should be updating the level here CurrentEXP += value; - OnEXPGained.ExecuteIfBound(); + OnEXPGained.ExecuteIfBound(value); + OnEXPLevelUp.ExecuteIfBound(CurrentLevel); } void UEXPComponent::SetCurrentEXP(int value) { // TODO: I should be updating the level here CurrentEXP = value; - OnEXPGained.ExecuteIfBound(); + OnEXPGained.ExecuteIfBound(value); } int UEXPComponent::GetCurrentEXP() @@ -41,6 +42,8 @@ void UEXPComponent::Reset() { CurrentEXP = 0; CurrentLevel = 0; + OnEXPGained.ExecuteIfBound(CurrentEXP); + OnEXPLevelUp.ExecuteIfBound(CurrentLevel); } // Called when the game starts diff --git a/Source/vampires/EXPComponent.h b/Source/vampires/EXPComponent.h index 021c89e..a593516 100644 --- a/Source/vampires/EXPComponent.h +++ b/Source/vampires/EXPComponent.h @@ -6,8 +6,8 @@ #include "Components/ActorComponent.h" #include "EXPComponent.generated.h" -DECLARE_DELEGATE(FOnEXPGainedDelegate) -DECLARE_DELEGATE(FOnEXPLevelUpDelegate) +DECLARE_DELEGATE_OneParam(FOnEXPGainedDelegate, int) +DECLARE_DELEGATE_OneParam(FOnEXPLevelUpDelegate, int) UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) class VAMPIRES_API UEXPComponent : public UActorComponent