// © 2025 Naked People Team. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "NakedDesire/Global/Constants.h"
#include "Subsystems/GameInstanceSubsystem.h"
#include "SaveSubsystem.generated.h"

class UGlobalSaveGameData;
struct FItemSaveRecord;

UCLASS()
class NAKEDDESIRE_API USaveSubsystem : public UGameInstanceSubsystem
{
	GENERATED_BODY()

public:
	void LoadGame(const FString& SlotName = DefaultSaveSlotName);
	bool SaveGame(const FString& SlotName = DefaultSaveSlotName) const;

	virtual void Initialize(FSubsystemCollectionBase& Collection) override;

	UGlobalSaveGameData* GetCurrentSave();
	
protected:
	UFUNCTION(BlueprintCallable)
	void BP_LoadGame();
	
	UFUNCTION(BlueprintCallable)
	void BP_SaveGame();

private:
	void PopulateStartingData(UGlobalSaveGameData* Save) const;

	UPROPERTY()
	FString ActiveSlotName = DefaultSaveSlotName;

	UPROPERTY()
	TObjectPtr<UGlobalSaveGameData> CurrentSave;
};