Added ClothingItemInstance and cleanup the project

This commit is contained in:
2026-05-20 23:26:26 +03:00
parent c29454fe38
commit c569adfd69
49 changed files with 252 additions and 391 deletions
@@ -1,25 +0,0 @@
// © 2025 Naked People Team. All Rights Reserved.
#include "ClothingItemData.h"
#include "../SaveGame/ClothingItemSaveData.h"
FClothingItemSaveData UClothingItemData::ToSaveData() const
{
FClothingItemSaveData SaveData;
SaveData.ClothingItem = Info;
return SaveData;
}
UClothingItemData* UClothingItemData::CreateFromSaveData(const FClothingItemSaveData& SaveData)
{
UClothingItem* ClothingItem = SaveData.ClothingItem.LoadSynchronous();
UClothingItemData* ClothingItemData = NewObject<UClothingItemData>();
ClothingItemData->Info = ClothingItem;
return ClothingItemData;
}
@@ -1,27 +0,0 @@
// © 2025 Naked People Team. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "ClothingItem.h"
#include "ClothingItemData.generated.h"
struct FClothingItemSaveData;
/**
*
*/
UCLASS(EditInlineNew, BlueprintType)
class NAKEDDESIRE_API UClothingItemData : public UObject
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly)
UClothingItem* Info = nullptr;
UFUNCTION(BlueprintCallable)
FClothingItemSaveData ToSaveData() const;
UFUNCTION(BlueprintCallable)
static UClothingItemData* CreateFromSaveData(const FClothingItemSaveData& SaveData);
};
@@ -0,0 +1,4 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "ClothingItemInstance.h"
@@ -0,0 +1,23 @@
#pragma once
#include "CoreMinimal.h"
#include "NakedDesire/Items/ItemInstance.h"
#include "ClothingItemInstance.generated.h"
class UClothingItem;
UCLASS(BlueprintType)
class NAKEDDESIRE_API UClothingItemInstance : public UItemInstance
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadOnly, Category = "Clothing Item")
float Condition = 1.0f;
UClothingItem* GetClothingItem() const { return ClothingItem; }
protected:
UPROPERTY(BlueprintReadOnly, Category = "Clothing Item")
TObjectPtr<UClothingItem> ClothingItem;
};
@@ -1,5 +0,0 @@
// © 2025 Naked People Team. All Rights Reserved.
#include "ClothingList.h"
@@ -1,22 +0,0 @@
// © 2025 Naked People Team. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Engine/DataAsset.h"
#include "ClothingList.generated.h"
class UClothingItemData;
/**
*
*/
UCLASS()
class NAKEDDESIRE_API UClothingList : public UPrimaryDataAsset
{
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Instanced)
TArray<UClothingItemData*> ClothingItems;
};
+41 -50
View File
@@ -2,9 +2,9 @@
#include "ClothingManager.h"
#include "ClothingItemData.h"
#include "ClothingItem.h"
#include "ClothingItemInstance.h"
#include "GameFramework/Character.h"
#include "NakedDesire/SaveGame/GlobalSaveGameData.h"
UClothingManager::UClothingManager()
{
@@ -15,7 +15,7 @@ bool UClothingManager::IsBodyTypeExposed(const EPrivateBodyPartType PrivateBodyP
{
for (const auto& ClothingSlot : ClothingSlots)
{
if (ClothingSlot.ClothingData && ClothingSlot.ClothingData->Info->CoveredBodyParts.Contains(PrivateBodyPartType))
if (ClothingSlot.ClothingItemInstance && ClothingSlot.ClothingItemInstance->GetClothingItem()->CoveredBodyParts.Contains(PrivateBodyPartType))
{
return false;
}
@@ -37,26 +37,26 @@ bool UClothingManager::GetClothingSlotData(const EClothingSlotType ClothingSlotT
return false;
}
void UClothingManager::SetClothingSlotItem(const EClothingSlotType ClothingSlotType, UClothingItemData* ClothingItem)
void UClothingManager::SetClothingSlotItem(const EClothingSlotType ClothingSlotType, UClothingItemInstance* ClothingItemInstance)
{
for (FClothingSlotData& ClothingSlot : ClothingSlots)
{
if (ClothingSlot.ClothingSlotType == ClothingSlotType)
{
ClothingSlot.ClothingData = ClothingItem;
ClothingSlot.ClothingItemInstance = ClothingItemInstance;
}
}
}
TArray<UClothingItemData*> UClothingManager::GetEquippedClothing()
TArray<UClothingItemInstance*> UClothingManager::GetEquippedClothing()
{
TArray<UClothingItemData*> EquippedClothingItems;
TArray<UClothingItemInstance*> EquippedClothingItems;
for (FClothingSlotData ClothingSlot : ClothingSlots)
{
if (ClothingSlot.ClothingData)
if (ClothingSlot.ClothingItemInstance)
{
EquippedClothingItems.Add(ClothingSlot.ClothingData);
EquippedClothingItems.Add(ClothingSlot.ClothingItemInstance);
}
}
@@ -65,110 +65,101 @@ TArray<UClothingItemData*> UClothingManager::GetEquippedClothing()
void UClothingManager::HydrateClothing(UGlobalSaveGameData* SaveGameData)
{
for (const FClothingItemSaveData& ClothingItemSaveData : SaveGameData->PlayerClothing)
{
UClothingItemData* ClothingItemData = UClothingItemData::CreateFromSaveData(ClothingItemSaveData);
PutOnClothing(ClothingItemData);
}
// for (const FClothingItemSaveData& ClothingItemSaveData : SaveGameData->PlayerClothing)
// {
// UClothingItemData* ClothingItemData = UClothingItemData::CreateFromSaveData(ClothingItemSaveData);
// PutOnClothing(ClothingItemData);
// }
}
float UClothingManager::GetHeelHeight()
{
if (FClothingSlotData ClothingSlotData; GetClothingSlotData(EClothingSlotType::Shoes, ClothingSlotData))
{
if (ClothingSlotData.ClothingData)
if (ClothingSlotData.ClothingItemInstance)
{
return ClothingSlotData.ClothingData->Info->ShoesOffset;
return ClothingSlotData.ClothingItemInstance->GetClothingItem()->ShoesOffset;
}
}
return 0;
}
void UClothingManager::PutOnClothing(UClothingItemData* ClothingData)
void UClothingManager::PutOnClothing(UClothingItemInstance* ClothingItemInstance)
{
if (!ClothingData)
{
if (!ClothingItemInstance)
return;
}
const EClothingSlotType ClothingSlotType = ClothingData->Info->SlotType;
const EClothingSlotType ClothingSlotType = ClothingItemInstance->GetClothingItem()->SlotType;
FClothingSlotData ClothingSlotData;
GetClothingSlotData(ClothingSlotType, ClothingSlotData);
ClothingSlotData.MeshComponent->SetSkeletalMesh(ClothingData->Info->SkeletalMesh);
if (!ClothingData->Info->Materials.IsEmpty())
ClothingSlotData.MeshComponent->SetSkeletalMesh(ClothingItemInstance->GetClothingItem()->SkeletalMesh);
if (!ClothingItemInstance->GetClothingItem()->Materials.IsEmpty())
{
for (const TPair<FName, UMaterialInstance*>& Material : ClothingData->Info->Materials)
for (const TPair<FName, UMaterialInstance*>& Material : ClothingItemInstance->GetClothingItem()->Materials)
{
ClothingSlotData.MeshComponent->SetMaterialByName(Material.Key, Material.Value);
}
}
SetClothingSlotItem(ClothingSlotType, ClothingData);
if (ClothingData->Info->UseLeaderPose)
SetClothingSlotItem(ClothingSlotType, ClothingItemInstance);
if (ClothingItemInstance->GetClothingItem()->UseLeaderPose)
{
ClothingSlotData.MeshComponent->SetLeaderPoseComponent(Cast<ACharacter>(GetOwner())->GetMesh());
}
OnClothingEquip.Broadcast(ClothingData);
OnClothingEquip.Broadcast(ClothingItemInstance);
}
void UClothingManager::TakeClothing(UClothingItemData* ClothingData)
void UClothingManager::TakeClothing(UClothingItemInstance* ClothingItemInstance)
{
if (!ClothingData->Info)
{
return;
}
FClothingSlotData ClothingSlotData;
GetClothingSlotData(ClothingData->Info->SlotType, ClothingSlotData);
GetClothingSlotData(ClothingItemInstance->GetClothingItem()->SlotType, ClothingSlotData);
if (ClothingSlotData.ClothingData->Info)
if (ClothingSlotData.ClothingItemInstance->GetClothingItem())
{
DropClothing(ClothingData->Info->SlotType);
DropClothing(ClothingItemInstance->GetClothingItem()->SlotType);
}
ClothingSlotData.ClothingData = ClothingData;
ClothingSlotData.ClothingItemInstance = ClothingItemInstance;
PutOnClothing(ClothingData);
PutOnClothing(ClothingItemInstance);
}
UClothingItemData* UClothingManager::RemoveClothing(const EClothingSlotType ClothingSlotType)
UClothingItemInstance* UClothingManager::RemoveClothing(const EClothingSlotType ClothingSlotType)
{
FClothingSlotData ClothingSlotData;
if (!GetClothingSlotData(ClothingSlotType, ClothingSlotData) || !ClothingSlotData.ClothingData)
if (!GetClothingSlotData(ClothingSlotType, ClothingSlotData) || !ClothingSlotData.ClothingItemInstance)
{
UE_LOG(LogTemp, Error, TEXT("Couldn't find clothing slot"));
return nullptr;
}
UClothingItemData* ClothingData = ClothingSlotData.ClothingData;
UClothingItemInstance* ClothingItemInstance = ClothingSlotData.ClothingItemInstance;
SetClothingSlotItem(ClothingSlotType, nullptr);
USkeletalMeshComponent* MeshComponent = ClothingSlotData.MeshComponent;
MeshComponent->SetSkeletalMesh(nullptr);
if (ClothingData->Info->UseLeaderPose)
if (ClothingItemInstance->GetClothingItem()->UseLeaderPose)
{
ClothingSlotData.MeshComponent->SetLeaderPoseComponent(nullptr);
}
OnClothingUnequip.Broadcast(ClothingData);
OnClothingUnequip.Broadcast(ClothingItemInstance);
return ClothingData;
return ClothingItemInstance;
}
void UClothingManager::DropClothing(const EClothingSlotType ClothingType)
{
const UClothingItemData* ClothingData = RemoveClothing(ClothingType);
if (!ClothingData)
{
const UClothingItemInstance* ClothingItemInstance = RemoveClothing(ClothingType);
if (!ClothingItemInstance)
return;
}
OnClothingDropped.Broadcast(ClothingData);
OnClothingDropped.Broadcast(ClothingItemInstance);
}
bool UClothingManager::IsClothingTypeOn(const EClothingSlotType ClothingType)
@@ -176,7 +167,7 @@ bool UClothingManager::IsClothingTypeOn(const EClothingSlotType ClothingType)
FClothingSlotData ClothingSlotData;
GetClothingSlotData(ClothingType, ClothingSlotData);
const bool IsTypeOn = ClothingSlotData.ClothingData != nullptr;
const bool IsTypeOn = ClothingSlotData.ClothingItemInstance != nullptr;
return IsTypeOn;
}
@@ -12,9 +12,9 @@
class UGlobalSaveGameData;
class AClothingPickup;
class UClothingItemData;
class UClothingItemInstance;
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnClothingChangeSignature, const UClothingItemData*, ClothingData);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnClothingChangeSignature, const UClothingItemInstance*, ClothingItemInstance);
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class NAKEDDESIRE_API UClothingManager : public UActorComponent
@@ -29,9 +29,7 @@ public:
UPROPERTY(BlueprintReadWrite, Category = "Clothing Manager|Clothing")
TArray<FClothingSlotData> ClothingSlots;
UPROPERTY(BlueprintAssignable)
FOnClothingChangeSignature OnClothingEquip;
@@ -43,7 +41,7 @@ public:
UFUNCTION(BlueprintCallable)
void PutOnClothing(UClothingItemData* ClothingData);
void PutOnClothing(UClothingItemInstance* ClothingItemInstance);
UFUNCTION(BlueprintCallable)
void DropClothing(const EClothingSlotType ClothingType);
@@ -58,19 +56,19 @@ public:
bool IsBodyTypeExposed(EPrivateBodyPartType PrivateBodyPartType);
UFUNCTION(BlueprintCallable)
void TakeClothing(UClothingItemData* ClothingData);
void TakeClothing(UClothingItemInstance* ClothingItemInstance);
UFUNCTION(BlueprintCallable)
UClothingItemData* RemoveClothing(EClothingSlotType ClothingSlotType);
UClothingItemInstance* RemoveClothing(EClothingSlotType ClothingSlotType);
UFUNCTION(BlueprintCallable)
bool GetClothingSlotData(EClothingSlotType ClothingSlotType, FClothingSlotData& OutClothingSlotData);
UFUNCTION(BlueprintCallable)
void SetClothingSlotItem(const EClothingSlotType ClothingSlotType, UClothingItemData* ClothingItem);
void SetClothingSlotItem(const EClothingSlotType ClothingSlotType, UClothingItemInstance* ClothingItemInstance);
UFUNCTION(BlueprintCallable)
TArray<UClothingItemData*> GetEquippedClothing();
TArray<UClothingItemInstance*> GetEquippedClothing();
void HydrateClothing(UGlobalSaveGameData* SaveGameData);
@@ -6,8 +6,8 @@
#include "ClothingSlotType.h"
#include "ClothingSlotData.generated.h"
class UClothingItemInstance;
enum class EClothingSlotType : uint8;
class UClothingItemData;
/**
*
@@ -18,26 +18,26 @@ struct NAKEDDESIRE_API FClothingSlotData
GENERATED_BODY()
FClothingSlotData()
: MeshComponent(nullptr), ClothingSlotType(EClothingSlotType::Anal), ClothingData(nullptr), Name(FText::GetEmpty())
: MeshComponent(nullptr), ClothingSlotType(EClothingSlotType::Anal), ClothingItemInstance(nullptr), Name(FText::GetEmpty())
{
}
FClothingSlotData(USkeletalMeshComponent* MeshComponent, const EClothingSlotType ClothingSlotType, UClothingItemData* ClothingData, const FText& Name)
FClothingSlotData(USkeletalMeshComponent* MeshComponent, const EClothingSlotType ClothingSlotType, UClothingItemInstance* ClothingItemInstance, const FText& Name)
{
this->MeshComponent = MeshComponent;
this->ClothingSlotType = ClothingSlotType;
this->ClothingData = ClothingData;
this->ClothingItemInstance = ClothingItemInstance;
this->Name = Name;
}
UPROPERTY(BlueprintReadWrite, Category = "Clothing")
USkeletalMeshComponent* MeshComponent = nullptr;
TObjectPtr<USkeletalMeshComponent> MeshComponent = nullptr;
UPROPERTY(BlueprintReadWrite, Category = "Clothing")
EClothingSlotType ClothingSlotType = EClothingSlotType::Anal;
UPROPERTY(BlueprintReadWrite, Category = "Clothing")
UClothingItemData* ClothingData = nullptr;
TObjectPtr<UClothingItemInstance> ClothingItemInstance = nullptr;
UPROPERTY(BlueprintReadWrite, Category = "Clothing")
FText Name = FText::GetEmpty();
@@ -4,9 +4,6 @@
#include "CoreMinimal.h"
/**
*
*/
UENUM(BlueprintType)
enum class EClothingSlotType : uint8
{
@@ -1,14 +0,0 @@
// © 2025 Naked People Team. All Rights Reserved.
#pragma once
#include "ClothingSlotWidgetData.generated.h"
USTRUCT(BlueprintType)
struct NAKEDDESIRE_API FClothingSlotWidgetData
{
GENERATED_BODY()
UPROPERTY(EditDefaultsOnly)
UTexture2D* PlaceholderIcon = nullptr;
};
@@ -3,14 +3,19 @@
#pragma once
#include "CoreMinimal.h"
#include "ClothingSlotWidgetData.h"
#include "ClothingSlotType.h"
#include "Engine/DataAsset.h"
#include "ClothingSlotWidgetsInfo.generated.h"
/**
*
*/
USTRUCT(BlueprintType)
struct NAKEDDESIRE_API FClothingSlotWidgetData
{
GENERATED_BODY()
UPROPERTY(EditDefaultsOnly)
UTexture2D* PlaceholderIcon = nullptr;
};
UCLASS()
class NAKEDDESIRE_API UClothingSlotInfo : public UPrimaryDataAsset
{