// Project Sword & Gun Copyright © 2021 Kevin Poretti

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "SNGHealthComponent.generated.h"

DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnHealthChangedSignature, USNGHealthComponent*, HealthComponent,
	float, Health, float, HealthDelta);

UCLASS( ClassGroup=(SwordNGun), meta=(BlueprintSpawnableComponent) )
class SWORDNGUN_API USNGHealthComponent : public UActorComponent
{
	GENERATED_BODY()

public:	
	// Sets default values for this component's properties
	USNGHealthComponent();

	UFUNCTION(BlueprintCallable)
	float GetHealth() const;

	UFUNCTION(BlueprintCallable)
	void AddHealth(float Delta);

	UFUNCTION (BlueprintCallable)
	void SubstractHealth(float Delta);
	
protected:
	// Called when the game starts
	virtual void BeginPlay() override;

	UPROPERTY(BlueprintReadOnly)
	float Health;		

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Health")
	float DefaultHealth;

public:
	UPROPERTY(BlueprintAssignable, Category = "Events")
	FOnHealthChangedSignature OnHealthChanged;
};
