Added ClothingItemInstance and cleanup the project

This commit is contained in:
koritsa
2026-05-20 23:26:26 +03:00
parent 1b2d9f9098
commit 8434d11b37
49 changed files with 252 additions and 391 deletions
+17 -19
View File
@@ -1,10 +1,8 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "PlayerImpostor.h"
#include "PlayerImpostor.h"
#include "NakedDesireCharacter.h"
#include "Kismet/GameplayStatics.h"
#include "NakedDesire/Clothing/ClothingItem.h"
#include "NakedDesire/Clothing/ClothingItemInstance.h"
#include "NakedDesire/Clothing/ClothingManager.h"
@@ -48,14 +46,14 @@ APlayerImpostor::APlayerImpostor()
ShoesMeshComponent->SetupAttachment(GetMesh());
}
void APlayerImpostor::OnClothingEquip(const UClothingItemData* ClothingData)
void APlayerImpostor::OnClothingEquip(const UClothingItemInstance* ClothingItemInstance)
{
EquipClothing(ClothingData);
EquipClothing(ClothingItemInstance);
}
void APlayerImpostor::OnClothingUnequip(const UClothingItemData* ClothingData)
void APlayerImpostor::OnClothingUnequip(const UClothingItemInstance* ClothingItemInstance)
{
UnequipClothing(ClothingData);
UnequipClothing(ClothingItemInstance);
}
void APlayerImpostor::BeginPlay()
@@ -71,9 +69,9 @@ void APlayerImpostor::BeginPlay()
Player->ClothingManager->OnClothingEquip.AddUniqueDynamic(this, &APlayerImpostor::OnClothingEquip);
Player->ClothingManager->OnClothingUnequip.AddUniqueDynamic(this, &APlayerImpostor::OnClothingUnequip);
for (const UClothingItemData* ClothingItemData : Player->ClothingManager->GetEquippedClothing())
for (const UClothingItemInstance* ClothingItemInstance : Player->ClothingManager->GetEquippedClothing())
{
EquipClothing(ClothingItemData);
EquipClothing(ClothingItemInstance);
}
}
@@ -114,27 +112,27 @@ USkeletalMeshComponent* APlayerImpostor::GetMeshByType(const EClothingSlotType S
}
}
void APlayerImpostor::EquipClothing(const UClothingItemData* ClothingData)
void APlayerImpostor::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 APlayerImpostor::UnequipClothing(const UClothingItemData* ClothingData)
void APlayerImpostor::UnequipClothing(const UClothingItemInstance* ClothingItemInstance)
{
USkeletalMeshComponent* MeshComponent = GetMeshByType(ClothingData->Info->SlotType);
USkeletalMeshComponent* MeshComponent = GetMeshByType(ClothingItemInstance->GetClothingItem()->SlotType);
MeshComponent->SetSkeletalMesh(nullptr);
MeshComponent->SetLeaderPoseComponent(nullptr);
}