Added starting save data

This commit is contained in:
koritsa
2026-05-27 19:43:00 +03:00
parent 1d6c77998e
commit 7dc63b87af
12 changed files with 109 additions and 53 deletions
+40 -3
View File
@@ -1,6 +1,14 @@
// © 2025 Naked People Team. All Rights Reserved.
#include "SaveSubsystem.h"
#include "GlobalSaveGameData.h"
#include "ItemSaveRecord.h"
#include "StartingSaveData.h"
#include "NakedDesire/Clothing/ClothingItem.h"
#include "NakedDesire/Clothing/ClothingItemInstance.h"
#include "NakedDesire/Global/NakedDesireGameInstance.h"
void USaveSubsystem::LoadGame(const FString& SlotName)
{
@@ -28,7 +36,7 @@ void USaveSubsystem::RemoveItem(const FGuid& InstanceId)
void USaveSubsystem::Initialize(FSubsystemCollectionBase& Collection)
{
Super::Initialize(Collection);
LoadGame();
}
@@ -36,8 +44,37 @@ UGlobalSaveGameData* USaveSubsystem::GetCurrentSave()
{
if (!CurrentSave)
{
CurrentSave = UGlobalSaveGameData::LoadOrCreateSaveGame(ActiveSlotName);
CurrentSave = UGlobalSaveGameData::LoadGame(ActiveSlotName);
if (!CurrentSave)
{
CurrentSave = UGlobalSaveGameData::CreateNewSaveGame();
PopulateStartingData(CurrentSave);
UGlobalSaveGameData::SaveGame(CurrentSave, ActiveSlotName);
}
}
return CurrentSave;
}
void USaveSubsystem::PopulateStartingData(UGlobalSaveGameData* Save) const
{
if (!Save)
return;
const UNakedDesireGameInstance* GameInstance = Cast<UNakedDesireGameInstance>(GetGameInstance());
if (!GameInstance || !GameInstance->StartingSaveData)
return;
for (UClothingItem* ClothingDef : GameInstance->StartingSaveData->StartingClothing)
{
if (!ClothingDef)
continue;
UClothingItemInstance* Instance = NewObject<UClothingItemInstance>(Save);
Instance->Init(ClothingDef);
FItemSaveRecord Record;
Record.Init(Instance);
Save->EquippedItems.Add(Record);
}
}