66 lines
1.5 KiB
C++
66 lines
1.5 KiB
C++
// © 2025 Naked People Team. All Rights Reserved.
|
|
|
|
|
|
#include "GlobalSaveGameData.h"
|
|
#include "NakedDesire/Global/Constants.h"
|
|
#include "Kismet/GameplayStatics.h"
|
|
|
|
UGlobalSaveGameData* UGlobalSaveGameData::CreateNewSaveGame()
|
|
{
|
|
UGlobalSaveGameData* NewSave = Cast<UGlobalSaveGameData>(
|
|
UGameplayStatics::CreateSaveGameObject(UGlobalSaveGameData::StaticClass())
|
|
);
|
|
|
|
if (!NewSave)
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
// NewSave->Money = InMoney;
|
|
|
|
// for (const UClothingItemData* Item : CurrentWardrobeClothing)
|
|
// {
|
|
// NewSave->WardrobeClothing.Add(Item->ToSaveData());
|
|
// }
|
|
//
|
|
// for (const UClothingItemData* Item : CurrentPlayerClothing)
|
|
// {
|
|
// NewSave->PlayerClothing.Add(Item->ToSaveData());
|
|
// }
|
|
|
|
return NewSave;
|
|
}
|
|
|
|
UGlobalSaveGameData* UGlobalSaveGameData::LoadOrCreateSaveGame()
|
|
{
|
|
if (UGameplayStatics::DoesSaveGameExist(SLOT_NAME, SLOT_PLAYER))
|
|
{
|
|
return Cast<UGlobalSaveGameData>(
|
|
UGameplayStatics::LoadGameFromSlot(SLOT_NAME, SLOT_PLAYER)
|
|
);
|
|
}
|
|
|
|
UGlobalSaveGameData* NewSave = nullptr;
|
|
// if (DefaultWardrobeClothing && DefaultPlayerClothing)
|
|
// {
|
|
// NewSave = CreateNewSaveGame(DefaultWardrobeClothing->ClothingItems, DefaultPlayerClothing->ClothingItems, STARTING_MONEY);
|
|
// }
|
|
|
|
if (NewSave)
|
|
{
|
|
UGameplayStatics::SaveGameToSlot(NewSave, SLOT_NAME, SLOT_PLAYER);
|
|
}
|
|
|
|
return NewSave;
|
|
}
|
|
|
|
bool UGlobalSaveGameData::SaveGame()
|
|
{
|
|
// if (UGlobalSaveGameData* Save = CreateNewSaveGame(CurrentWardrobeClothing, CurrentPlayerClothing, (float)InMoney))
|
|
// {
|
|
// return UGameplayStatics::SaveGameToSlot(Save, SLOT_NAME, SLOT_PLAYER);
|
|
// }
|
|
|
|
return false;
|
|
}
|