Add parameters to Event Delegates

This commit is contained in:
baz 2024-07-18 01:39:27 +01:00
parent addeb47c04
commit 686294ab41
2 changed files with 7 additions and 4 deletions

View File

@ -17,14 +17,15 @@ void UEXPComponent::IncrementEXP(int value)
{ {
// TODO: I should be updating the level here // TODO: I should be updating the level here
CurrentEXP += value; CurrentEXP += value;
OnEXPGained.ExecuteIfBound(); OnEXPGained.ExecuteIfBound(value);
OnEXPLevelUp.ExecuteIfBound(CurrentLevel);
} }
void UEXPComponent::SetCurrentEXP(int value) void UEXPComponent::SetCurrentEXP(int value)
{ {
// TODO: I should be updating the level here // TODO: I should be updating the level here
CurrentEXP = value; CurrentEXP = value;
OnEXPGained.ExecuteIfBound(); OnEXPGained.ExecuteIfBound(value);
} }
int UEXPComponent::GetCurrentEXP() int UEXPComponent::GetCurrentEXP()
@ -41,6 +42,8 @@ void UEXPComponent::Reset()
{ {
CurrentEXP = 0; CurrentEXP = 0;
CurrentLevel = 0; CurrentLevel = 0;
OnEXPGained.ExecuteIfBound(CurrentEXP);
OnEXPLevelUp.ExecuteIfBound(CurrentLevel);
} }
// Called when the game starts // Called when the game starts

View File

@ -6,8 +6,8 @@
#include "Components/ActorComponent.h" #include "Components/ActorComponent.h"
#include "EXPComponent.generated.h" #include "EXPComponent.generated.h"
DECLARE_DELEGATE(FOnEXPGainedDelegate) DECLARE_DELEGATE_OneParam(FOnEXPGainedDelegate, int)
DECLARE_DELEGATE(FOnEXPLevelUpDelegate) DECLARE_DELEGATE_OneParam(FOnEXPLevelUpDelegate, int)
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class VAMPIRES_API UEXPComponent : public UActorComponent class VAMPIRES_API UEXPComponent : public UActorComponent