#pragma once

#include "CoreMinimal.h"
#include "AnniversaryPlayerComponentInterface.h"
#include "EventObjectItemWidgetInterface.h"
#include "Components/ActorComponent.h"
#include "SpeedBasedNetSyncedValue.h"
#include "GameplayTagContainer.h"
#include "DBDTunableRowHandle.h"
#include "Templates/SubclassOf.h"
#include "InvitationPlayerComponent.generated.h"

class UTimerObject;
class UInteractionDefinition;
class UInteractionAttacherComponent;
class ADBDPlayer;
class AActor;

UCLASS(Blueprintable, Abstract, meta=(BlueprintSpawnableComponent))
class ANNIVERSARY_API UInvitationPlayerComponent : public UActorComponent, public IAnniversaryPlayerComponentInterface, public IEventObjectItemWidgetInterface
{
	GENERATED_BODY()

protected:
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	bool _isInEndGame;

	UPROPERTY(BlueprintReadWrite, Replicated, Transient)
	FSpeedBasedNetSyncedValue _invitationCharges;

	UPROPERTY(BlueprintReadWrite, ReplicatedUsing=OnRep_InvitationChargesInt, Transient)
	int32 _invitationChargesInt;

	UPROPERTY(BlueprintReadWrite, ReplicatedUsing=OnRep_CooldownTimer, Transient, Instanced)
	UTimerObject* _cooldownTimer;

	UPROPERTY(EditAnywhere)
	FGameplayTagQuery _particleVFXDeactivateTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	FDBDTunableRowHandle _invitationChargeGain;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	FDBDTunableRowHandle _maxNumberOfCharges;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	FDBDTunableRowHandle _chargeRechargeRateInChase;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	FDBDTunableRowHandle _chargeRechargeRate;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	FDBDTunableRowHandle _abilityCooldown;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	bool _canRechargeOutOfChase;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	TArray<TSubclassOf<UInteractionDefinition>> _invitationInteractionClasses;

	UPROPERTY(EditAnywhere)
	FGameplayTagQuery _disablingPlayerTargetComponentTagsQuery;

private:
	UPROPERTY(BlueprintReadWrite, Transient, Instanced, meta=(AllowPrivateAccess=true))
	UInteractionAttacherComponent* _interactionAttacherComponent;

protected:
	UFUNCTION(BlueprintCallable)
	void OnRep_InvitationChargesInt();

	UFUNCTION(BlueprintCallable)
	void OnRep_CooldownTimer();

	UFUNCTION(BlueprintCallable)
	void OnLevelReadyToPlay();

	UFUNCTION(BlueprintCallable, NetMulticast, Reliable)
	void Multicast_CosmeticOnInvitationInteractionActivate(ADBDPlayer* player, AActor* target);

	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_SetVFXParticlesVisibility(bool isVisible);

	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_OnPlayerInChaseStateChanged(bool inChase);

	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_OnInvitationInteractionReady(bool isReady);

	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_OnInvitationInteractionActivate(ADBDPlayer* abilityCaster, AActor* target);

	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_OnInvitationChargesIntChanged(int32 invitationCharge);

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

public:
	UInvitationPlayerComponent();
};

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