// © 2025 Naked People Team. All Rights Reserved. #include "GlobalSaveGameData.h" #include "NakedDesire/Global/Constants.h" #include "Kismet/GameplayStatics.h" #include "NakedDesire/Clothing/ClothingItemData.h" #include "NakedDesire/Clothing/ClothingList.h" UGlobalSaveGameData* UGlobalSaveGameData::CreateNewSaveGame(TArray CurrentWardrobeClothing, TArray CurrentPlayerClothing) { UGlobalSaveGameData* NewSave = Cast( UGameplayStatics::CreateSaveGameObject(UGlobalSaveGameData::StaticClass()) ); if (!NewSave) { return nullptr; } 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(UClothingList* DefaultPlayerClothing, UClothingList* DefaultWardrobeClothing) { if (UGameplayStatics::DoesSaveGameExist(SLOT_NAME, SLOT_PLAYER)) { return Cast( UGameplayStatics::LoadGameFromSlot(SLOT_NAME, SLOT_PLAYER) ); } UGlobalSaveGameData* NewSave = nullptr; if (DefaultWardrobeClothing && DefaultPlayerClothing) { NewSave = CreateNewSaveGame(DefaultWardrobeClothing->ClothingItems, DefaultPlayerClothing->ClothingItems); } if (NewSave) { UGameplayStatics::SaveGameToSlot(NewSave, SLOT_NAME, SLOT_PLAYER); } return NewSave; } bool UGlobalSaveGameData::SaveGame(const TArray CurrentWardrobeClothing, const TArray CurrentPlayerClothing) { if (UGlobalSaveGameData* SaveGame = CreateNewSaveGame(CurrentWardrobeClothing, CurrentPlayerClothing)) { return UGameplayStatics::SaveGameToSlot(SaveGame, SLOT_NAME, SLOT_PLAYER); } return false; }