Added ClothingItemInstance and cleanup the project
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user