Completed phase 1

This commit is contained in:
2026-05-25 14:14:52 +03:00
parent 799fc8a4ae
commit 43ddad9217
22 changed files with 255 additions and 55 deletions
@@ -1 +1,27 @@
#include "ClothingItemInstance.h"
#include "ClothingItem.h"
#include "NakedDesire/SaveGame/ItemSaveRecord.h"
void UClothingItemInstance::Init(UClothingItem* InClothingItem)
{
ClothingItem = InClothingItem;
}
void UClothingItemInstance::Setup(UClothingItem* InClothingItem, const TArray<UItemInstance*>& InStoredItems,
const float InCondition, const FGuid InInstanceId)
{
this->ClothingItem = InClothingItem;
this->StoredItems = InStoredItems;
this->Condition = InCondition;
this->InstanceId = InInstanceId;
}
UClothingItemInstance* UClothingItemInstance::CreateFromSave(UObject* Outer, const FItemSaveRecord& ItemSaveRecord)
{
UClothingItemInstance* NewItemInstance = NewObject<UClothingItemInstance>(Outer);
NewItemInstance->Setup(ItemSaveRecord.Definition.Get(), {}, ItemSaveRecord.Condition, ItemSaveRecord.InstanceId);
return NewItemInstance;
}
@@ -4,6 +4,7 @@
#include "NakedDesire/Items/ItemInstance.h"
#include "ClothingItemInstance.generated.h"
struct FItemSaveRecord;
class UClothingItem;
UCLASS(BlueprintType)
@@ -17,6 +18,11 @@ public:
UClothingItem* GetClothingItem() const { return ClothingItem; }
void Init(UClothingItem* InClothingItem);
void Setup(UClothingItem* InClothingItem, const TArray<UItemInstance*>& InStoredItems, float InCondition, FGuid InInstanceId);
static UClothingItemInstance* CreateFromSave(UObject* Outer, const FItemSaveRecord& ItemSaveRecord);
protected:
UPROPERTY(BlueprintReadOnly, Category = "Clothing Item")
TObjectPtr<UClothingItem> ClothingItem;
@@ -5,12 +5,23 @@
#include "ClothingItem.h"
#include "ClothingItemInstance.h"
#include "GameFramework/Character.h"
#include "Kismet/GameplayStatics.h"
#include "NakedDesire/SaveGame/GlobalSaveGameData.h"
#include "NakedDesire/SaveGame/ItemSaveRecord.h"
#include "NakedDesire/SaveGame/SaveSubsystem.h"
UClothingManager::UClothingManager()
{
PrimaryComponentTick.bCanEverTick = false;
}
void UClothingManager::BeginPlay()
{
Super::BeginPlay();
HydrateClothing();
}
bool UClothingManager::IsBodyTypeExposed(const EBodyPart BodyPart)
{
for (const auto& ClothingSlot : ClothingSlots)
@@ -63,13 +74,14 @@ TArray<UClothingItemInstance*> UClothingManager::GetEquippedClothing()
return EquippedClothingItems;
}
void UClothingManager::HydrateClothing(UGlobalSaveGameData* SaveGameData)
void UClothingManager::HydrateClothing()
{
// for (const FClothingItemSaveData& ClothingItemSaveData : SaveGameData->PlayerClothing)
// {
// UClothingItemData* ClothingItemData = UClothingItemData::CreateFromSaveData(ClothingItemSaveData);
// PutOnClothing(ClothingItemData);
// }
USaveSubsystem* SaveSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<USaveSubsystem>();
for (const FItemSaveRecord& ItemSaveRecord : SaveSubsystem->GetCurrentSave()->EquippedItems)
{
UClothingItemInstance* ClothingItemInstance = UClothingItemInstance::CreateFromSave(this, ItemSaveRecord);
PutOnClothing(ClothingItemInstance);
}
}
float UClothingManager::GetHeelHeight()
@@ -109,6 +121,22 @@ void UClothingManager::PutOnClothing(UClothingItemInstance* ClothingItemInstance
{
ClothingSlotData.MeshComponent->SetLeaderPoseComponent(Cast<ACharacter>(GetOwner())->GetMesh());
}
UClothingItem* ClothingItem = ClothingItemInstance->GetClothingItem();
if (ClothingItem->SlotType == EClothingSlotType::Bodysuit)
{
DropClothing(EClothingSlotType::Top);
DropClothing(EClothingSlotType::Bottom);
DropClothing(EClothingSlotType::UnderwearTop);
DropClothing(EClothingSlotType::UnderwearBottom);
}
else if (ClothingItem->SlotType == EClothingSlotType::Top ||
ClothingItem->SlotType == EClothingSlotType::Bottom ||
ClothingItem->SlotType == EClothingSlotType::UnderwearTop ||
ClothingItem->SlotType == EClothingSlotType::UnderwearBottom)
{
DropClothing(EClothingSlotType::Bodysuit);
}
OnClothingEquip.Broadcast(ClothingItemInstance);
}
@@ -125,6 +153,16 @@ void UClothingManager::TakeClothing(UClothingItemInstance* ClothingItemInstance)
ClothingSlotData.ClothingItemInstance = ClothingItemInstance;
USaveSubsystem* SaveSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<USaveSubsystem>();
FItemSaveRecord ItemSaveRecord;
ItemSaveRecord.Init(ClothingItemInstance);
SaveSubsystem->GetCurrentSave()->EquippedItems.Push(ItemSaveRecord);
SaveSubsystem->GetCurrentSave()->DroppedItems.RemoveAll([ClothingItemInstance](const FItemSaveRecord& Item)
{
return Item.InstanceId == ClothingItemInstance->GetInstanceId();
});
PutOnClothing(ClothingItemInstance);
}
@@ -149,6 +187,12 @@ UClothingItemInstance* UClothingManager::RemoveClothing(const EClothingSlotType
}
OnClothingUnequip.Broadcast(ClothingItemInstance);
USaveSubsystem* SaveSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<USaveSubsystem>();
SaveSubsystem->GetCurrentSave()->EquippedItems.RemoveAll([ClothingItemInstance](const FItemSaveRecord& Item)
{
return Item.InstanceId == ClothingItemInstance->GetInstanceId();
});
return ClothingItemInstance;
}
@@ -158,6 +202,11 @@ void UClothingManager::DropClothing(const EClothingSlotType ClothingType)
const UClothingItemInstance* ClothingItemInstance = RemoveClothing(ClothingType);
if (!ClothingItemInstance)
return;
USaveSubsystem* SaveSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<USaveSubsystem>();
FItemSaveRecord ItemSaveRecord;
ItemSaveRecord.Init(ClothingItemInstance);
SaveSubsystem->GetCurrentSave()->DroppedItems.Push(ItemSaveRecord);
OnClothingDropped.Broadcast(ClothingItemInstance);
}
@@ -21,6 +21,8 @@ class NAKEDDESIRE_API UClothingManager : public UActorComponent
public:
UClothingManager();
virtual void BeginPlay() override;
UPROPERTY(BlueprintReadWrite, Category = "Clothing Manager|Clothing")
USkeletalMeshComponent* RootMesh = nullptr;
@@ -36,7 +38,6 @@ public:
UPROPERTY(BlueprintAssignable)
FOnClothingChangeSignature OnClothingDropped;
UFUNCTION(BlueprintCallable)
void PutOnClothing(UClothingItemInstance* ClothingItemInstance);
@@ -68,7 +69,7 @@ public:
UFUNCTION(BlueprintCallable)
TArray<UClothingItemInstance*> GetEquippedClothing();
void HydrateClothing(UGlobalSaveGameData* SaveGameData);
void HydrateClothing();
UFUNCTION(BlueprintPure)
float GetHeelHeight();
@@ -14,7 +14,7 @@ enum class EClothingSlotType : uint8
Neck,
Face,
Eyes,
BodySuit,
Bodysuit,
Top,
Bottom,
UnderwearTop,
@@ -10,6 +10,7 @@
#include "NakedDesire/MissionBuilder/MissionsManager.h"
#include "NakedDesire/Player/NakedDesireCharacter.h"
#include "NakedDesire/SaveGame/GlobalSaveGameData.h"
#include "NakedDesire/SaveGame/SaveSubsystem.h"
void ANakedDesireGameMode::RestartGame()
{
@@ -23,7 +24,8 @@ AWardrobe* ANakedDesireGameMode::GetWardrobe() const
void ANakedDesireGameMode::BuyItem(UClothingItemInstance* ClothingItemInstance)
{
UGlobalSaveGameData* SaveGame = UGlobalSaveGameData::LoadGame();
USaveSubsystem* SaveSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<USaveSubsystem>();
UGlobalSaveGameData* SaveGame = SaveSubsystem->GetCurrentSave();
if (!SaveGame)
{
UE_LOG(LogTemp, Error, TEXT("ANakedDesireGameMode::BuyItem Couldn't load save game"));
@@ -31,19 +33,25 @@ void ANakedDesireGameMode::BuyItem(UClothingItemInstance* ClothingItemInstance)
}
if (SaveGame->Money < ClothingItemInstance->GetClothingItem()->BasePrice)
{
return;
}
SaveGame->Money -= ClothingItemInstance->GetClothingItem()->BasePrice;
Wardrobe->ClothingItems.Add(ClothingItemInstance);
Wardrobe->AddItem(ClothingItemInstance);
}
void ANakedDesireGameMode::OnHourChanged(int32 Hour)
{
USaveSubsystem* SaveSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<USaveSubsystem>();
UGlobalSaveGameData* SaveGame = SaveSubsystem->GetCurrentSave();
if (!SaveGame)
{
UE_LOG(LogTemp, Error, TEXT("ANakedDesireGameMode::BuyItem Couldn't load save game"));
return;
}
if (Hour == 4)
{
DaysPassed++;
SaveGame->DaysPassed++;
RefreshDailyMissions();
}
}
@@ -63,12 +71,12 @@ void ANakedDesireGameMode::BeginPlay()
void ANakedDesireGameMode::RefreshDailyMissions()
{
ANakedDesireCharacter* Player = Cast<ANakedDesireCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));
const ANakedDesireCharacter* Player = Cast<ANakedDesireCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));
if (!Player)
{
return;
}
int ClampedIndex = FMath::Clamp(DaysPassed, 0, MissionsConfig->DailyMissions.Num() - 1);
USaveSubsystem* SaveSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<USaveSubsystem>();
int ClampedIndex = FMath::Clamp(SaveSubsystem->GetCurrentSave()->DaysPassed , 0, MissionsConfig->DailyMissions.Num() - 1);
Player->MissionsManager->RefreshDailyMissions(MissionsConfig->DailyMissions[ClampedIndex].Missions);
}
@@ -21,8 +21,6 @@ class ANakedDesireGameMode : public AGameModeBase
UPROPERTY(EditDefaultsOnly)
UMissionsConfig* MissionsConfig;
int32 DaysPassed = 0;
public:
int NoticeCount = 0;
@@ -30,9 +28,6 @@ public:
UFUNCTION(BlueprintPure, BlueprintImplementableEvent)
FTimecode GetCurrentTime() const;
UFUNCTION(BlueprintPure, BlueprintImplementableEvent)
int32 GetDaysElapsed() const;
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable)
void SetCurrentTime(FTimecode TimeCode);
@@ -30,6 +30,5 @@ class NAKEDDESIRE_API AInteractableBase : public AActor, public IInteractionTarg
public:
AInteractableBase();
protected:
virtual void Tick(float DeltaSeconds) override;
};
@@ -3,3 +3,42 @@
#include "Wardrobe.h"
#include "Kismet/GameplayStatics.h"
#include "NakedDesire/SaveGame/GlobalSaveGameData.h"
#include "NakedDesire/SaveGame/ItemSaveRecord.h"
#include "NakedDesire/SaveGame/SaveSubsystem.h"
void AWardrobe::AddItem(UClothingItemInstance* ClothingItemInstance)
{
USaveSubsystem* SaveSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<USaveSubsystem>();
ClothingItems.Push(ClothingItemInstance);
FItemSaveRecord ItemSaveRecord;
ItemSaveRecord.Init(ClothingItemInstance);
SaveSubsystem->GetCurrentSave()->WardrobeItems.Push(ItemSaveRecord);
}
void AWardrobe::RemoveItem(UClothingItemInstance* ClothingItemInstance) const
{
USaveSubsystem* SaveSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<USaveSubsystem>();
SaveSubsystem->GetCurrentSave()->WardrobeItems.RemoveAll([ClothingItemInstance](const FItemSaveRecord& Item)
{
return Item.InstanceId == ClothingItemInstance->GetInstanceId();
});
}
void AWardrobe::BeginPlay()
{
Super::BeginPlay();
USaveSubsystem* SaveSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<USaveSubsystem>();
UGlobalSaveGameData* SaveGame = SaveSubsystem->GetCurrentSave();
for (const FItemSaveRecord& ItemSaveRecord : SaveGame->WardrobeItems)
{
UClothingItemInstance* NewItemInstance = UClothingItemInstance::CreateFromSave(this, ItemSaveRecord);
ClothingItems.Push(NewItemInstance);
}
}
@@ -17,4 +17,9 @@ class NAKEDDESIRE_API AWardrobe : public AInteractableBase
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced)
TArray<TObjectPtr<UClothingItemInstance>> ClothingItems;
void AddItem(UClothingItemInstance* ClothingItemInstance);
void RemoveItem(UClothingItemInstance* ClothingItemInstance) const;
virtual void BeginPlay() override;
};
+3 -3
View File
@@ -6,12 +6,12 @@ void UItemInstance::PostInitProperties()
if (HasAnyFlags(RF_ClassDefaultObject | RF_ArchetypeObject | RF_NeedLoad))
return;
if (!InstanceID.IsValid())
InstanceID = FGuid::NewGuid();
if (!InstanceId.IsValid())
InstanceId = FGuid::NewGuid();
}
void UItemInstance::PostDuplicate(EDuplicateMode::Type DuplicateMode)
{
Super::PostDuplicate(DuplicateMode);
InstanceID = FGuid::NewGuid();
InstanceId = FGuid::NewGuid();
}
+3 -3
View File
@@ -14,9 +14,9 @@ public:
virtual void PostDuplicate(EDuplicateMode::Type DuplicateMode) override;
UFUNCTION(BlueprintPure, Category = "Item")
FGuid GetInstanceID() const { return InstanceID; }
FGuid GetInstanceId() const { return InstanceId; }
private:
protected:
UPROPERTY(VisibleAnywhere, SaveGame, BlueprintReadOnly, Category = "Item", meta = (AllowPrivateAccess = "true"))
FGuid InstanceID;
FGuid InstanceId;
};
+5 -5
View File
@@ -11,18 +11,18 @@ class NAKEDDESIRE_API USexToyItem : public UPrimaryDataAsset
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sed Toy")
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sex Toy")
float LustModifier = 0.0f;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sed Toy")
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sex Toy")
float EmbarrassmentModifier = 0.0f;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sed Toy")
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sex Toy")
float PulseModifier = 0.0f;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sed Toy")
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sex Toy")
bool HasVibration = false;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sed Toy")
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sex Toy")
EClothingSlotType SlotType = EClothingSlotType::Anal;
};
@@ -404,9 +404,9 @@ void ANakedDesireCharacter::SetupClothingSlots()
LOCTEXT("Eyes", "Eyes")));
ClothingManager->ClothingSlots.Add(
FClothingSlotData(
BodySuitMeshComponent, EClothingSlotType::BodySuit,
BodySuitMeshComponent, EClothingSlotType::Bodysuit,
nullptr,
LOCTEXT("BodySuit", "BodySuit")));
LOCTEXT("Bodysuit", "Bodysuit")));
ClothingManager->ClothingSlots.Add(
FClothingSlotData(
TopMeshComponent, EClothingSlotType::Top,
@@ -88,7 +88,7 @@ USkeletalMeshComponent* APlayerCinematic::GetMeshByType(const EClothingSlotType
return FaceMeshComponent;
case EClothingSlotType::Eyes:
return EyesMeshComponent;
case EClothingSlotType::BodySuit:
case EClothingSlotType::Bodysuit:
return BodyMeshComponent;
case EClothingSlotType::Top:
return TopMeshComponent;
+1 -1
View File
@@ -93,7 +93,7 @@ USkeletalMeshComponent* APlayerImpostor::GetMeshByType(const EClothingSlotType S
return FaceMeshComponent;
case EClothingSlotType::Eyes:
return EyesMeshComponent;
case EClothingSlotType::BodySuit:
case EClothingSlotType::Bodysuit:
return BodyMeshComponent;
case EClothingSlotType::Top:
return TopMeshComponent;
@@ -8,10 +8,10 @@
UGlobalSaveGameData* UGlobalSaveGameData::CreateNewSaveGame()
{
UGlobalSaveGameData* NewSave = Cast<UGlobalSaveGameData>(UGameplayStatics::CreateSaveGameObject(StaticClass()));
NewSave->Money = STARTING_MONEY;
if (!NewSave)
return nullptr;
NewSave->Money = STARTING_MONEY;
return NewSave;
}
@@ -41,12 +41,7 @@ UGlobalSaveGameData* UGlobalSaveGameData::LoadGame(const FString& SlotName)
return nullptr;
}
bool UGlobalSaveGameData::SaveGame(const FString& SlotName)
bool UGlobalSaveGameData::SaveGame(UGlobalSaveGameData* SaveGameData, const FString& SlotName)
{
if (UGlobalSaveGameData* Save = CreateNewSaveGame())
{
return UGameplayStatics::SaveGameToSlot(Save, SlotName, SLOT_PLAYER);
}
return false;
return UGameplayStatics::SaveGameToSlot(SaveGameData, SlotName, SLOT_PLAYER);
}
@@ -17,7 +17,7 @@ class NAKEDDESIRE_API UGlobalSaveGameData : public USaveGame
public:
static UGlobalSaveGameData* LoadOrCreateSaveGame(const FString& SlotName = DefaultSaveSlotName);
static UGlobalSaveGameData* LoadGame(const FString& SlotName = DefaultSaveSlotName);
static bool SaveGame(const FString& SlotName = DefaultSaveSlotName);
static bool SaveGame(UGlobalSaveGameData* SaveGameData, const FString& SlotName = DefaultSaveSlotName);
UPROPERTY(SaveGame)
bool HaveSeenTutorial = false;
@@ -31,6 +31,9 @@ public:
UPROPERTY(SaveGame)
TArray<FItemSaveRecord> EquippedItems;
UPROPERTY(SaveGame)
TArray<FItemSaveRecord> DroppedItems;
UPROPERTY(SaveGame)
int32 DaysPassed = 0;
+15 -1
View File
@@ -1,9 +1,11 @@
#pragma once
#include "CoreMinimal.h"
#include "NakedDesire/Clothing/ClothingItemInstance.h"
#include "NakedDesire/Clothing/ClothingItem.h"
#include "ItemSaveRecord.generated.h"
class UClothingItem;
class UClothingItemInstance;
USTRUCT()
struct NAKEDDESIRE_API FItemSaveRecord
@@ -21,4 +23,16 @@ struct NAKEDDESIRE_API FItemSaveRecord
UPROPERTY(SaveGame)
FGuid ParentId;
UPROPERTY(SaveGame)
FTransform WorldTransform;
void Init(const UClothingItemInstance* ClothingItemInstance);
};
inline void FItemSaveRecord::Init(const UClothingItemInstance* ClothingItemInstance)
{
InstanceId = ClothingItemInstance->GetInstanceId();
Definition = ClothingItemInstance->GetClothingItem();
Condition = ClothingItemInstance->Condition;
}
+13 -3
View File
@@ -4,12 +4,12 @@
void USaveSubsystem::LoadGame(const FString& SlotName)
{
UGlobalSaveGameData* Save = UGlobalSaveGameData::LoadGame(SlotName);
CurrentSave = UGlobalSaveGameData::LoadGame(SlotName);
}
bool USaveSubsystem::SaveGame(const FString& SlotName)
bool USaveSubsystem::SaveGame(const FString& SlotName) const
{
return UGlobalSaveGameData::SaveGame(SlotName);
return UGlobalSaveGameData::SaveGame(CurrentSave, SlotName);
}
void USaveSubsystem::AddItem(const FItemSaveRecord& Record)
@@ -31,3 +31,13 @@ void USaveSubsystem::Initialize(FSubsystemCollectionBase& Collection)
LoadGame();
}
UGlobalSaveGameData* USaveSubsystem::GetCurrentSave()
{
if (!CurrentSave)
{
CurrentSave = UGlobalSaveGameData::LoadOrCreateSaveGame(ActiveSlotName);
}
return CurrentSave;
}
+3 -1
View File
@@ -15,7 +15,7 @@ class NAKEDDESIRE_API USaveSubsystem : public UGameInstanceSubsystem
public:
void LoadGame(const FString& SlotName = DefaultSaveSlotName);
bool SaveGame(const FString& SlotName = DefaultSaveSlotName);
bool SaveGame(const FString& SlotName = DefaultSaveSlotName) const;
const TArray<FItemSaveRecord>& GetItems() const { return Items; }
void AddItem(const FItemSaveRecord& Record);
@@ -23,6 +23,8 @@ public:
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
UGlobalSaveGameData* GetCurrentSave();
private:
UPROPERTY()
FString ActiveSlotName = DefaultSaveSlotName;