#include "SaveSubsystem.h"
#include "GlobalSaveGameData.h"
#include "ItemSaveRecord.h"

void USaveSubsystem::LoadGame(const FString& SlotName)
{
	UGlobalSaveGameData* Save = UGlobalSaveGameData::LoadGame(SlotName);
}

bool USaveSubsystem::SaveGame(const FString& SlotName)
{
	return UGlobalSaveGameData::SaveGame(SlotName);
}

void USaveSubsystem::AddItem(const FItemSaveRecord& Record)
{
	Items.Add(Record);
}

void USaveSubsystem::RemoveItem(const FGuid& InstanceId)
{
	FItemSaveRecord* ItemSaveRecord = Items.FindByPredicate([InstanceId](FItemSaveRecord ItemSaveRecord)
	{
		return ItemSaveRecord.InstanceId == InstanceId;
	});
	if (ItemSaveRecord)
	{
		Items.Remove(*ItemSaveRecord);
	}
}

void USaveSubsystem::Initialize(FSubsystemCollectionBase& Collection)
{
	Super::Initialize(Collection);
	
	LoadGame();
}
