Added starting save data
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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;
|
||||
|
||||
@@ -10,38 +10,23 @@ UGlobalSaveGameData* UGlobalSaveGameData::CreateNewSaveGame()
|
||||
UGlobalSaveGameData* NewSave = Cast<UGlobalSaveGameData>(UGameplayStatics::CreateSaveGameObject(StaticClass()));
|
||||
if (!NewSave)
|
||||
return nullptr;
|
||||
|
||||
|
||||
NewSave->Money = STARTING_MONEY;
|
||||
|
||||
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))
|
||||
{
|
||||
return Cast<UGlobalSaveGameData>(UGameplayStatics::LoadGameFromSlot(SlotName, SLOT_PLAYER));
|
||||
}
|
||||
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool UGlobalSaveGameData::SaveGame(UGlobalSaveGameData* SaveGameData, const FString& SlotName)
|
||||
{
|
||||
return UGameplayStatics::SaveGameToSlot(SaveGameData, SlotName, SLOT_PLAYER);
|
||||
}
|
||||
}
|
||||
@@ -15,31 +15,28 @@ 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);
|
||||
|
||||
|
||||
UPROPERTY(SaveGame)
|
||||
bool HaveSeenTutorial = false;
|
||||
|
||||
UPROPERTY(SaveGame)
|
||||
float Money = 0;
|
||||
|
||||
|
||||
UPROPERTY(SaveGame)
|
||||
TArray<FItemSaveRecord> WardrobeItems;
|
||||
|
||||
|
||||
UPROPERTY(SaveGame)
|
||||
TArray<FItemSaveRecord> EquippedItems;
|
||||
|
||||
|
||||
UPROPERTY(SaveGame)
|
||||
TArray<FItemSaveRecord> DroppedItems;
|
||||
|
||||
|
||||
UPROPERTY(SaveGame)
|
||||
int32 DaysPassed = 0;
|
||||
|
||||
|
||||
UPROPERTY(SaveGame)
|
||||
float HourOfDay = 0.0f;
|
||||
|
||||
private:
|
||||
static UGlobalSaveGameData* CreateNewSaveGame();
|
||||
};
|
||||
};
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
@@ -12,26 +14,28 @@ UCLASS()
|
||||
class NAKEDDESIRE_API USaveSubsystem : public UGameInstanceSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
public:
|
||||
void LoadGame(const FString& SlotName = DefaultSaveSlotName);
|
||||
bool SaveGame(const FString& SlotName = DefaultSaveSlotName) const;
|
||||
|
||||
|
||||
const TArray<FItemSaveRecord>& GetItems() const { return Items; }
|
||||
void AddItem(const FItemSaveRecord& Record);
|
||||
void RemoveItem(const FGuid& InstanceId);
|
||||
|
||||
|
||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
||||
|
||||
|
||||
UGlobalSaveGameData* GetCurrentSave();
|
||||
|
||||
|
||||
private:
|
||||
void PopulateStartingData(UGlobalSaveGameData* Save) const;
|
||||
|
||||
UPROPERTY()
|
||||
FString ActiveSlotName = DefaultSaveSlotName;
|
||||
|
||||
|
||||
UPROPERTY()
|
||||
TArray<FItemSaveRecord> Items;
|
||||
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<UGlobalSaveGameData> CurrentSave;
|
||||
};
|
||||
};
|
||||
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user