#pragma once

#include "CoreMinimal.h"
#include "Collectable.h"
#include "Templates/SubclassOf.h"
#include "DBDTunableRowHandle.h"
#include "GameplayTagContainer.h"
#include "GameEventData.h"
#include "K22Power.generated.h"

class UChargeableComponent;
class UStatusEffect;
class AConjoinedTwin;
class UPowerChargeComponent;
class UK22PowerChargePresentationItemProgressComponent;
class UK22PowerFadeComponent;

UCLASS(Blueprintable)
class AK22Power : public ACollectable
{
	GENERATED_BODY()

protected:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient, meta=(BindWidgetOptional))
	UChargeableComponent* _releaseConjoinedTwinChargeable;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient, meta=(BindWidgetOptional))
	UChargeableComponent* _possessConjoinedTwinChargeable;

private:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	TSubclassOf<UStatusEffect> _killerDormantStealthStatusEffectClass;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, ReplicatedUsing=OnRep_ConjoinedTwin, Transient, meta=(AllowPrivateAccess=true))
	AConjoinedTwin* _conjoinedTwin;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	AConjoinedTwin* _conjoinedTwinParadise;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient, Export, meta=(AllowPrivateAccess=true))
	UPowerChargeComponent* _powerCharge;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient, Export, meta=(AllowPrivateAccess=true))
	UK22PowerChargePresentationItemProgressComponent* _powerChargePresentationItemProgress;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient, Export, meta=(AllowPrivateAccess=true))
	UK22PowerFadeComponent* _powerFadeComponent;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	FDBDTunableRowHandle _powerMaxCharge;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	TSubclassOf<AConjoinedTwin> _conjoinedTwinClass;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	FDBDTunableRowHandle _defaultPowerRechargeTime;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	FDBDTunableRowHandle _powerRechargeTimeAfterTwinKicked;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	FDBDTunableRowHandle _timeBeforeAutoDestroy;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	FDBDTunableRowHandle _timeBeforeRecallFromDormant;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	FDBDTunableRowHandle _timeBeforeRecallFromAttachedSurvivor;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	FDBDTunableRowHandle _timeBeforeRecallFromLocker;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, ReplicatedUsing=OnRep_RecallReady, meta=(AllowPrivateAccess=true))
	bool _recallReady;

private:
	UFUNCTION(BlueprintCallable)
	void OnRep_RecallReady();

	UFUNCTION(BlueprintCallable)
	void OnRep_ConjoinedTwin();

	UFUNCTION(BlueprintCallable)
	void OnPowerChargeEmpty();

	UFUNCTION(BlueprintCallable)
	void OnFirstAttachmentToSister();

public:
	UFUNCTION(BlueprintPure)
	AConjoinedTwin* GetConjoinedTwin() const;

private:
	UFUNCTION()
	void Authority_TwinDestroyedBySurvivor(const FGameplayTag gameplayTag, const FGameEventData& gameEventData);

	UFUNCTION(BlueprintCallable)
	void Authority_OnPossessTwinChargePercentChanged(UChargeableComponent* chargeableComponent, float percentCompletionChange, float totalPercentComplete);

	UFUNCTION(BlueprintCallable)
	void Authority_OnDestroyTwinChargePercentChanged(UChargeableComponent* chargeableComponent, float percentCompletionChange, float totalPercentComplete);

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

public:
	AK22Power();
};

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