// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

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

/**
 *  Simple GameMode for a third person game
 */
UCLASS(abstract)
class AAgrarianGameGameMode : public AGameModeBase
{
	GENERATED_BODY()

public:
	
	/** Constructor */
	AAgrarianGameGameMode();

	virtual void BeginPlay() override;
	virtual void RestartPlayer(AController* NewPlayer) override;
	virtual void Logout(AController* Exiting) override;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Persistence", meta = (ClampMin = "0"))
	float ServerAutoSaveIntervalSeconds = 300.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Persistence")
	bool bLoadWorldOnServerStart = true;

protected:
	void RegisterPersistentActorClasses(UAgrarianPersistenceSubsystem* Persistence) const;
	void LoadWorldOnServerStart();
	void RunServerAutoSave();

	FTimerHandle ServerAutoSaveTimerHandle;
};



