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
Binary file not shown.
Binary file not shown.
+2 -2
View File
@@ -14,10 +14,10 @@ struct NAKEDDESIRE_API FBodyPartCoverage
{
GENERATED_BODY()
UPROPERTY()
UPROPERTY(EditDefaultsOnly)
float Coverage = 1.0f;
UPROPERTY()
UPROPERTY(EditDefaultsOnly)
EBodyPart BodyPart = EBodyPart::Ass;
};
@@ -153,7 +153,7 @@ void UClothingManager::PutOnClothing(UClothingItemInstance* ClothingItemInstance
void UClothingManager::TakeClothing(UClothingItemInstance* ClothingItemInstance)
{
const EClothingSlotType SlotType = ClothingItemInstance->GetClothingItem()->SlotType;
if (const UClothingItemInstance* ExistingClothing = *EquippedClothing.Find(SlotType))
if (EquippedClothing.Contains(SlotType))
{
DropClothing(SlotType);
}
@@ -175,10 +175,17 @@ void UClothingManager::TakeClothing(UClothingItemInstance* ClothingItemInstance)
UClothingItemInstance* UClothingManager::RemoveClothing(const EClothingSlotType ClothingSlotType)
{
UClothingItemInstance* ExistingItem = *EquippedClothing.Find(ClothingSlotType);
TObjectPtr<UClothingItemInstance>* ExistingItemRef = EquippedClothing.Find(ClothingSlotType);
if (!ExistingItemRef)
{
UE_LOG(LogTemp, Warning, TEXT("UClothingManager::RemoveClothing ExistingItemRef == nullptr"));
return nullptr;
}
UClothingItemInstance* ExistingItem = *ExistingItemRef;
if (!ExistingItem)
{
UE_LOG(LogTemp, Warning, TEXT("UClothingManager::RemoveClothing No clothing found"));
UE_LOG(LogTemp, Warning, TEXT("UClothingManager::RemoveClothing ExistingItem == nullptr"));
return nullptr;
}
@@ -5,11 +5,14 @@
#include "CoreMinimal.h"
#include "NakedDesireGameInstance.generated.h"
/**
*
*/
class UStartingSaveData;
UCLASS()
class NAKEDDESIRE_API UNakedDesireGameInstance : public UGameInstance
{
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly, Category = "Save")
TObjectPtr<UStartingSaveData> StartingSaveData;
};
@@ -14,6 +14,7 @@
#include "NakedDesireCharacter.generated.h"
class ANakedDesireHUD;
class UClothingItem;
class UClothingItemInstance;
class UClothingSlotsData;
class URadialMenuController;
@@ -16,21 +16,6 @@ UGlobalSaveGameData* UGlobalSaveGameData::CreateNewSaveGame()
return NewSave;
}
UGlobalSaveGameData* UGlobalSaveGameData::LoadOrCreateSaveGame(const FString& SlotName)
{
if (UGlobalSaveGameData* ExistingSave = LoadGame(SlotName))
return ExistingSave;
UGlobalSaveGameData* NewSave = CreateNewSaveGame();
if (NewSave)
{
UGameplayStatics::SaveGameToSlot(NewSave, SlotName, SLOT_PLAYER);
}
return NewSave;
}
UGlobalSaveGameData* UGlobalSaveGameData::LoadGame(const FString& SlotName)
{
if (UGameplayStatics::DoesSaveGameExist(SlotName, SLOT_PLAYER))
@@ -15,7 +15,7 @@ class NAKEDDESIRE_API UGlobalSaveGameData : public USaveGame
GENERATED_BODY()
public:
static UGlobalSaveGameData* LoadOrCreateSaveGame(const FString& SlotName = DefaultSaveSlotName);
static UGlobalSaveGameData* CreateNewSaveGame();
static UGlobalSaveGameData* LoadGame(const FString& SlotName = DefaultSaveSlotName);
static bool SaveGame(UGlobalSaveGameData* SaveGameData, const FString& SlotName = DefaultSaveSlotName);
@@ -39,7 +39,4 @@ public:
UPROPERTY(SaveGame)
float HourOfDay = 0.0f;
private:
static UGlobalSaveGameData* CreateNewSaveGame();
};
+38 -1
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)
{
@@ -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);
}
}
@@ -1,3 +1,5 @@
// © 2025 Naked People Team. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
@@ -26,6 +28,8 @@ public:
UGlobalSaveGameData* GetCurrentSave();
private:
void PopulateStartingData(UGlobalSaveGameData* Save) const;
UPROPERTY()
FString ActiveSlotName = DefaultSaveSlotName;
@@ -0,0 +1,19 @@
// © 2025 Naked People Team. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Engine/DataAsset.h"
#include "StartingSaveData.generated.h"
class UClothingItem;
UCLASS()
class NAKEDDESIRE_API UStartingSaveData : public UPrimaryDataAsset
{
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly, Category = "Starting State")
TArray<TObjectPtr<UClothingItem>> StartingClothing;
};