#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Templates/SubclassOf.h"
#include "DBDTunableRowHandle.h"
#include "ESteamPipeState.h"
#include "SteamPipeManagerComponent.generated.h"

class USteamPipeEffectComponent;
class UChargeableComponent;
class ASteamPipe;
class ASteamPipeResetSwitch;
class ADBDPlayer;
class AActor;

UCLASS(Blueprintable, meta=(BlueprintSpawnableComponent))
class DBDGAMEPLAY_API USteamPipeManagerComponent : public UActorComponent
{
	GENERATED_BODY()

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

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	TSubclassOf<UChargeableComponent> _chargeableComponentClass;

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

	UPROPERTY(EditInstanceOnly, BlueprintReadWrite, Replicated, Transient, Instanced, meta=(AllowPrivateAccess=true))
	UChargeableComponent* _sharedChargeableComponent;

	UPROPERTY(EditInstanceOnly, Transient)
	TArray<TWeakObjectPtr<ASteamPipe>> _steamPipes;

	UPROPERTY(EditInstanceOnly, Transient)
	TArray<TWeakObjectPtr<ASteamPipeResetSwitch>> _steamPipeResetSwitches;

	UPROPERTY(EditInstanceOnly, Transient)
	TArray<TWeakObjectPtr<ADBDPlayer>> _interactingPlayersArray;

private:
	UFUNCTION(BlueprintCallable)
	void OnLevelReadyToPlay();

	UFUNCTION(BlueprintCallable)
	void Authority_UpdateCanUseResetSwitch();

	UFUNCTION(BlueprintCallable)
	void Authority_OnSwitchCooldownComplete();

	UFUNCTION(BlueprintCallable)
	void Authority_OnSteamPipeStateChanged(const ASteamPipe* steamPipe, const ESteamPipeState newState);

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

	UFUNCTION(BlueprintCallable)
	void Authority_OnCharacterAdded(ADBDPlayer* character);

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

public:
	USteamPipeManagerComponent();
};

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