#pragma once

#include "CoreMinimal.h"
#include "ContainsItemInterface.h"
#include "Interactable.h"
#include "EK32ItemBoxState.h"
#include "DBDTunableRowHandle.h"
#include "K32ItemBox.generated.h"

class UChargeableComponent;
class ACollectable;
class USceneComponent;
class UK32ItemBoxSpeedUpInteraction;
class UInteractor;
class UPrimitiveComponent;
class UDBDOutlineComponent;
class UDBDSkeletalMeshComponentBudgeted;
class ADBDPlayer;
class AKiller;
class AActor;

UCLASS(Blueprintable)
class THEK32_API AK32ItemBox : public AInteractable, public IContainsItemInterface
{
	GENERATED_BODY()

protected:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced)
	UChargeableComponent* _chargeable;

	UPROPERTY(EditInstanceOnly, BlueprintReadWrite, ReplicatedUsing=OnRep_SpawnedItem, Transient)
	ACollectable* _spawnedItem;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced)
	USceneComponent* _containingItemSpawnPoint;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced)
	USceneComponent* _itemDropPoint;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, ReplicatedUsing=OnRep_State)
	EK32ItemBoxState _state;

private:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, NoClear, Instanced, meta=(AllowPrivateAccess=true))
	UK32ItemBoxSpeedUpInteraction* _itemBoxSpeedUpInteraction;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, NoClear, Instanced, meta=(AllowPrivateAccess=true))
	UInteractor* _interactor;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, NoClear, Instanced, meta=(AllowPrivateAccess=true))
	UPrimitiveComponent* _interactionZone;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, NoClear, Instanced, meta=(AllowPrivateAccess=true))
	UDBDOutlineComponent* _outlineComponent;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced, meta=(AllowPrivateAccess=true))
	UDBDSkeletalMeshComponentBudgeted* _skeletalMeshComponent;

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

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

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

	UPROPERTY(EditAnywhere, BlueprintReadWrite, ReplicatedUsing=OnRep_IsSurvivorInteracting, meta=(AllowPrivateAccess=true))
	bool _isSurvivorInteracting;

	UPROPERTY(EditInstanceOnly, BlueprintReadWrite, Transient, meta=(AllowPrivateAccess=true))
	ADBDPlayer* _survivorInteracting;

	UPROPERTY(EditInstanceOnly, BlueprintReadWrite, Transient, meta=(AllowPrivateAccess=true))
	AKiller* _killer;

private:
	UFUNCTION(BlueprintCallable)
	void OnRep_State();

	UFUNCTION(BlueprintCallable)
	void OnRep_SpawnedItem();

	UFUNCTION(BlueprintCallable)
	void OnRep_IsSurvivorInteracting();

	UFUNCTION(BlueprintCallable)
	void OnChargeableCompleteEvent(bool completed, const TArray<AActor*>& instigatorsForCompletion);

	UFUNCTION(BlueprintCallable, NetMulticast, Reliable)
	void Multicast_SetIsChargeTimeExtended(const bool isAddonExtendingFirstActivationTimer);

protected:
	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_OnSurvivorInteractingChanged(bool isInteracting);

	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_OnStateChanged(EK32ItemBoxState newState);

private:
	UFUNCTION(BlueprintCallable)
	void Authority_OnItemPickup(ADBDPlayer* player);

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

public:
	AK32ItemBox();
};

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