Added starting save data
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user