#pragma once

#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "HyperTwistMelindaProjectionGameMode.generated.h"

class AHyperTwistMelindaProjectionActor;
class AHyperTwistMelindaProjectionOrbitPawn;
class AHyperTwistMelindaProjectionPlayerController;

UCLASS(BlueprintType, Blueprintable)
class UNREALHYPERTWIST_API AHyperTwistMelindaProjectionGameMode : public AGameModeBase
{
	GENERATED_BODY()

public:
	AHyperTwistMelindaProjectionGameMode();

	virtual void BeginPlay() override;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist|Melinda")
	bool bAutoSpawnProjectionActor = true;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist|Melinda")
	TSubclassOf<AHyperTwistMelindaProjectionActor> ProjectionActorClass;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist|Melinda")
	FVector ProjectionSpawnLocation = FVector(0.0f, 0.0f, 160.0f);

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist|Melinda")
	FRotator ProjectionSpawnRotation = FRotator::ZeroRotator;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist|Melinda")
	bool bRandomizeOnBeginPlay = false;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist|Melinda")
	int32 StartupRandomSeed = 2026;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist|Melinda|Persistence")
	bool bLoadSavedStateOnBeginPlay = true;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "HyperTwist|Melinda")
	TObjectPtr<AHyperTwistMelindaProjectionActor> ActiveProjectionActor = nullptr;

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Melinda")
	void ResetProjectionToSolved();

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Melinda")
	bool GenerateProjectionRandomState(int32 RandomSeed);

protected:
	AHyperTwistMelindaProjectionActor* ResolveOrSpawnProjectionActor();
};
