#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 TArray<FItemSaveRecord>& GetItems() const { return Items; }
	void AddItem(const FItemSaveRecord& Record);
	void RemoveItem(const FGuid& InstanceId);
	
	virtual void Initialize(FSubsystemCollectionBase& Collection) override;
	
private:
	UPROPERTY()
	FString ActiveSlotName = DefaultSaveSlotName;
	
	UPROPERTY()
	TArray<FItemSaveRecord> Items;
	
	UPROPERTY()
	TObjectPtr<UGlobalSaveGameData> CurrentSave;
};
