// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "HealthSegmentStruct.h"
#include "Components/ActorComponent.h"
#include "DDIHealth.generated.h"

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class OPENCONFLICT_API UDDIHealth : public UActorComponent
{
	GENERATED_BODY()
/*UPROPERTY and UFUNCTION declarations*/
private:
	/*Properties*/

	/*Functions*/
	UFUNCTION(BlueprintAuthorityOnly, BlueprintCallable, Category = "Health")
	void Heal();

protected:
	/*Properties*/
	UPROPERTY(BlueprintReadOnly, Category = "Health")
	int MaxHealth; //Stores the default max health of component
	UPROPERTY(BlueprintReadOnly, Category = "Health")
	int CurrentHealth; //Stores the active health of component
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Health")
	float HealTickTime; //Time in Seconds between heal ticks
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Health")
	float HealDelayTime; //Time in Seconds before heal ticks
	
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stage")
	UDataTable* HealthSegmentTable;
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stage")
	ClassNames ClassName;

	/*Functions*/

public:
	/*Properties*/

	/*Functions*/
	UFUNCTION(BlueprintAuthorityOnly, BlueprintCallable, Category = "Health")
	void TakeDamage(int DamageValue);

	/*C++ only declarations*/
private:
	/*Properties*/

	/*Functions*/

protected:
	/*Properties*/
	TArray<int> HealthSegments;

	FTimerHandle HealTimer; // Called to begin healing
	// FTimerManager& TimerManager = GetWorld()->GetTimerManager();

	/*Functions*/
	// Called when the game starts
	virtual void BeginPlay() override;

public:
	/*Properties*/

	/*Functions*/
	// Sets default values for this component's properties
	UDDIHealth();

	// Called every frame
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
		
};
