#pragma once

#include "CoreMinimal.h"
#include "Interactable.h"
#include "DBDTunableRowHandle.h"
#include "Templates/SubclassOf.h"
#include "VoidStation.generated.h"

class UStaticMeshComponent;
class UInteractor;
class UPrimitiveComponent;
class UCollectVoidBombInteraction;
class UChargeableComponent;
class UVoidStationEnergyInteraction;
class UDBDOutlineComponent;
class UVoidStationOutlineStrategy;
class ADBDPlayer;
class ULocalPlayerTrackerComponent;

UCLASS(Blueprintable)
class AVoidStation : public AInteractable
{
	GENERATED_BODY()

protected:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced)
	UStaticMeshComponent* _voidBombMesh;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced)
	UStaticMeshComponent* _voidStationMesh;

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

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

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced, meta=(AllowPrivateAccess=true))
	UCollectVoidBombInteraction* _collectVoidBombInteraction;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced, meta=(AllowPrivateAccess=true))
	UChargeableComponent* _collectVoidBombChargeable;

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

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	TSubclassOf<UVoidStationEnergyInteraction> _depositVoidEnergyKillerTemplate;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	TSubclassOf<UVoidStationEnergyInteraction> _depositVoidEnergySurvivorTemplate;

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

	UPROPERTY(EditAnywhere, BlueprintReadWrite, NoClear, Instanced, meta=(AllowPrivateAccess=true))
	UVoidStationOutlineStrategy* _outlineStrategy;

	UPROPERTY(ReplicatedUsing=OnRep_PlayerCraftedVoidBomb, Transient)
	TWeakObjectPtr<ADBDPlayer> _playerCraftedVoidBomb;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced, meta=(AllowPrivateAccess=true))
	ULocalPlayerTrackerComponent* _localPlayerTracker;

private:
	UFUNCTION(BlueprintCallable)
	void OnRep_PlayerCraftedVoidBomb();

	UFUNCTION(BlueprintCallable)
	void OnLocallyObservedChanged();

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

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

	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_OnItemCrafted(bool itemCrafted, bool killerItem);

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

public:
	AVoidStation();
};

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