#pragma once

#include "CoreMinimal.h"
#include "GameplayModifierContainer.h"
#include "Templates/SubclassOf.h"
#include "OnPermanentlyDisabledBP.h"
#include "OnTokenCountChangedBP.h"
#include "EPerkTokenSoundStrategy.h"
#include "Competence.generated.h"

class UBasePerkIconStrategy;
class UTimerObject;

UCLASS(Blueprintable, meta=(BlueprintSpawnableComponent))
class DEADBYDAYLIGHT_API UCompetence : public UGameplayModifierContainer
{
	GENERATED_BODY()

public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	TSubclassOf<UBasePerkIconStrategy> PerkIconStrategyClass;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, BlueprintAssignable)
	FOnPermanentlyDisabledBP OnPermanentlyDisabledBP;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, BlueprintAssignable)
	FOnTokenCountChangedBP OnTokenCountChangedBP;

private:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, ReplicatedUsing=OnRep_CooldownTimer, Transient, Export, meta=(AllowPrivateAccess=true))
	UTimerObject* _cooldownTimer;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Transient, Export, meta=(AllowPrivateAccess=true))
	UTimerObject* _hudIconTimer;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	bool SetInactiveDuringCooldown;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient, meta=(AllowPrivateAccess=true))
	UBasePerkIconStrategy* _perkIconStrategy;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, ReplicatedUsing=OnRep_IsDisabled, Transient, meta=(AllowPrivateAccess=true))
	bool _isDisabled;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, ReplicatedUsing=OnRep_TokenCount, Transient, meta=(AllowPrivateAccess=true))
	int32 _tokenCount;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, meta=(AllowPrivateAccess=true))
	int32 _maxTokenCount;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	EPerkTokenSoundStrategy _tokenSoundStrategy;

private:
	UFUNCTION(BlueprintCallable)
	void OnRep_TokenCount(int32 oldCount);

	UFUNCTION(BlueprintCallable)
	void OnRep_IsDisabled(bool disabled);

	UFUNCTION(BlueprintCallable)
	void OnRep_CooldownTimer() const;

public:
	UFUNCTION(BlueprintPure)
	bool IsPermanentlyDisabled() const;

	UFUNCTION(BlueprintPure)
	bool IsHudIconTimerDone() const;

	UFUNCTION(BlueprintPure)
	bool IsHudIconTimerActive() const;

	UFUNCTION(BlueprintPure)
	bool IsCooldownTimerDone() const;

	UFUNCTION(BlueprintPure)
	int32 GetTokenCount() const;

	UFUNCTION(BlueprintPure)
	UBasePerkIconStrategy* GetPerkIconStrategy() const;

	UFUNCTION(BlueprintPure)
	int32 GetMaxTokenCount() const;

	UFUNCTION(BlueprintPure)
	float GetHudIconTimerRemainingTime() const;

	UFUNCTION(BlueprintPure)
	float GetHudIconTimerElapsedTimePercent() const;

	UFUNCTION(BlueprintPure)
	UTimerObject* GetCooldownTimer() const;

	UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly)
	void Authority_TriggerHudIconTimer(float duration);

	UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly)
	void Authority_TriggerCooldownTimer(const float duration);

	UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly)
	void Authority_SetTokenCount(int32 value);

	UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly)
	void Authority_SetPermanentlyDisabled(bool disabled);

	UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly)
	void Authority_SetMaxTokenCount(int32 value);

	UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly)
	void Authority_IncrementToken();

	UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly)
	void Authority_DecrementToken();

public:
	virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;

public:
	UCompetence();
};

FORCEINLINE uint32 GetTypeHash(const UCompetence) { return 0; }
