vampires/Source/vampires/EXPComponent.h

62 lines
1.4 KiB
C
Raw Normal View History

2025-02-05 23:12:03 +00:00
// Louis Hobbs | 2024-2025
2024-06-12 19:06:51 +01:00
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "TableRows/ExpTableRow.h"
2024-06-12 19:06:51 +01:00
#include "EXPComponent.generated.h"
2024-11-16 02:18:36 +00:00
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnEXPGainedDelegate, int, exp, float, currentLevelPercent);
2025-07-29 22:06:42 +01:00
2024-11-16 02:18:36 +00:00
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnEXPLevelUpDelegate, int, level);
2024-06-12 19:06:51 +01:00
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class VAMPIRES_API UEXPComponent : public UActorComponent
{
GENERATED_BODY()
public:
2024-11-16 02:18:36 +00:00
UPROPERTY(BlueprintAssignable, Category="EXP")
2024-06-12 19:06:51 +01:00
FOnEXPGainedDelegate OnEXPGained;
2025-07-29 22:06:42 +01:00
2024-11-16 02:18:36 +00:00
UPROPERTY(BlueprintAssignable, Category="EXP")
2024-06-12 19:06:51 +01:00
FOnEXPLevelUpDelegate OnEXPLevelUp;
UPROPERTY(EditDefaultsOnly, Category="EXP")
TObjectPtr<UDataTable> LevelsTable;
2025-07-29 22:06:42 +01:00
private:
2024-06-12 19:06:51 +01:00
int CurrentEXP = 0;
int CurrentLevel = 0;
FExpTableRow NextLevelRow;
2024-06-12 19:06:51 +01:00
public:
// Sets default values for this component's properties
UEXPComponent();
2024-08-14 00:19:47 +01:00
UFUNCTION(BlueprintCallable)
2025-07-29 22:06:42 +01:00
void IncrementEXP(int Value);
2024-06-12 19:06:51 +01:00
2024-08-14 00:19:47 +01:00
UFUNCTION(BlueprintCallable)
2025-07-29 22:06:42 +01:00
void SetCurrentEXP(int Value);
2024-06-12 19:06:51 +01:00
2024-08-14 00:19:47 +01:00
UFUNCTION(BlueprintCallable, BlueprintPure)
2024-06-12 19:06:51 +01:00
int GetCurrentEXP();
2024-08-14 00:19:47 +01:00
UFUNCTION(BlueprintCallable, BlueprintPure)
2024-06-12 19:06:51 +01:00
int GetCurrentLevel();
2024-08-14 00:19:47 +01:00
UFUNCTION(BlueprintCallable)
2024-06-12 19:06:51 +01:00
void Reset();
2024-08-20 23:32:24 +01:00
UFUNCTION(BlueprintCallable, BlueprintPure)
float GetCurrentLevelPercent();
2024-06-12 19:06:51 +01:00
protected:
// Called when the game starts
virtual void BeginPlay() override;
};