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
+17 -20
View File
@@ -1,11 +1,8 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "PlayerCinematic.h"
#include "PlayerCinematic.h"
#include "NakedDesireCharacter.h"
#include "Kismet/GameplayStatics.h"
#include "NakedDesire/Clothing/ClothingItemData.h"
#include "NakedDesire/Clothing/ClothingItem.h"
#include "NakedDesire/Clothing/ClothingItemInstance.h"
#include "NakedDesire/Clothing/ClothingManager.h"
@@ -57,20 +54,20 @@ void APlayerCinematic::BeginPlay()
Player->ClothingManager->OnClothingEquip.AddUniqueDynamic(this, &APlayerCinematic::OnClothingEquip);
Player->ClothingManager->OnClothingUnequip.AddUniqueDynamic(this, &APlayerCinematic::OnClothingUnequip);
for (const UClothingItemData* ClothingItemData : Player->ClothingManager->GetEquippedClothing())
for (const UClothingItemInstance* ClothingItemInstance : Player->ClothingManager->GetEquippedClothing())
{
EquipClothing(ClothingItemData);
EquipClothing(ClothingItemInstance);
}
}
void APlayerCinematic::OnClothingEquip(const UClothingItemData* ClothingData)
void APlayerCinematic::OnClothingEquip(const UClothingItemInstance* ClothingItemInstance)
{
EquipClothing(ClothingData);
EquipClothing(ClothingItemInstance);
}
void APlayerCinematic::OnClothingUnequip(const UClothingItemData* ClothingData)
void APlayerCinematic::OnClothingUnequip(const UClothingItemInstance* ClothingItemInstance)
{
UnequipClothing(ClothingData);
UnequipClothing(ClothingItemInstance);
}
USkeletalMeshComponent* APlayerCinematic::GetMeshByType(const EClothingSlotType SlotType) const
@@ -110,27 +107,27 @@ USkeletalMeshComponent* APlayerCinematic::GetMeshByType(const EClothingSlotType
}
}
void APlayerCinematic::EquipClothing(const UClothingItemData* ClothingData)
void APlayerCinematic::EquipClothing(const UClothingItemInstance* ClothingItemInstance)
{
USkeletalMeshComponent* MeshComponent = GetMeshByType(ClothingData->Info->SlotType);
MeshComponent->SetSkeletalMesh(ClothingData->Info->SkeletalMesh);
if (ClothingData->Info->UseLeaderPose)
USkeletalMeshComponent* MeshComponent = GetMeshByType(ClothingItemInstance->GetClothingItem()->SlotType);
MeshComponent->SetSkeletalMesh(ClothingItemInstance->GetClothingItem()->SkeletalMesh);
if (ClothingItemInstance->GetClothingItem()->UseLeaderPose)
{
MeshComponent->SetLeaderPoseComponent(GetMesh());
}
if (!ClothingData->Info->Materials.IsEmpty())
if (!ClothingItemInstance->GetClothingItem()->Materials.IsEmpty())
{
for (const TPair<FName, UMaterialInstance*>& Material : ClothingData->Info->Materials)
for (const TPair<FName, UMaterialInstance*>& Material : ClothingItemInstance->GetClothingItem()->Materials)
{
MeshComponent->SetMaterialByName(Material.Key, Material.Value);
}
}
}
void APlayerCinematic::UnequipClothing(const UClothingItemData* ClothingData)
void APlayerCinematic::UnequipClothing(const UClothingItemInstance* ClothingItemInstance)
{
USkeletalMeshComponent* MeshComponent = GetMeshByType(ClothingData->Info->SlotType);
USkeletalMeshComponent* MeshComponent = GetMeshByType(ClothingItemInstance->GetClothingItem()->SlotType);
MeshComponent->SetSkeletalMesh(nullptr);
MeshComponent->SetLeaderPoseComponent(nullptr);
}