#include "PlayerCinematic.h" #include "NakedDesireCharacter.h" #include "Kismet/GameplayStatics.h" #include "NakedDesire/Clothing/ClothingItem.h" #include "NakedDesire/Clothing/ClothingItemInstance.h" #include "NakedDesire/Clothing/ClothingManager.h" // Sets default values APlayerCinematic::APlayerCinematic() { PrimaryActorTick.bCanEverTick = false; NipplesMeshComponent = CreateDefaultSubobject(TEXT("Nipples")); NipplesMeshComponent->SetupAttachment(GetMesh()); AnalMeshComponent = CreateDefaultSubobject(TEXT("Anal")); AnalMeshComponent->SetupAttachment(GetMesh()); VaginaMeshComponent = CreateDefaultSubobject(TEXT("Vagina")); VaginaMeshComponent->SetupAttachment(GetMesh()); HeadMeshComponent = CreateDefaultSubobject(TEXT("Head")); HeadMeshComponent->SetupAttachment(GetMesh()); NeckMeshComponent = CreateDefaultSubobject(TEXT("Neck")); NeckMeshComponent->SetupAttachment(GetMesh()); FaceMeshComponent = CreateDefaultSubobject(TEXT("Face")); FaceMeshComponent->SetupAttachment(GetMesh()); EyesMeshComponent = CreateDefaultSubobject(TEXT("Eyes")); EyesMeshComponent->SetupAttachment(GetMesh()); BodyMeshComponent = CreateDefaultSubobject(TEXT("Body")); BodyMeshComponent->SetupAttachment(GetMesh()); TopMeshComponent = CreateDefaultSubobject(TEXT("Top")); TopMeshComponent->SetupAttachment(GetMesh()); BottomMeshComponent = CreateDefaultSubobject(TEXT("Bottom")); BottomMeshComponent->SetupAttachment(GetMesh()); BraMeshComponent = CreateDefaultSubobject(TEXT("Bra")); BraMeshComponent->SetupAttachment(GetMesh()); PantiesMeshComponent = CreateDefaultSubobject(TEXT("Panties")); PantiesMeshComponent->SetupAttachment(GetMesh()); SocksMeshComponent = CreateDefaultSubobject(TEXT("Socks")); SocksMeshComponent->SetupAttachment(GetMesh()); ShoesMeshComponent = CreateDefaultSubobject(TEXT("Shoes")); ShoesMeshComponent->SetupAttachment(GetMesh()); } void APlayerCinematic::BeginPlay() { Super::BeginPlay(); Player = Cast(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0)); if (!Player) { return; } Player->ClothingManager->OnClothingEquip.AddUniqueDynamic(this, &APlayerCinematic::OnClothingEquip); Player->ClothingManager->OnClothingUnequip.AddUniqueDynamic(this, &APlayerCinematic::OnClothingUnequip); for (const UClothingItemInstance* ClothingItemInstance : Player->ClothingManager->GetEquippedClothing()) { EquipClothing(ClothingItemInstance); } } void APlayerCinematic::OnClothingEquip(UClothingItemInstance* ClothingItemInstance) { EquipClothing(ClothingItemInstance); } void APlayerCinematic::OnClothingUnequip(UClothingItemInstance* ClothingItemInstance) { UnequipClothing(ClothingItemInstance); } USkeletalMeshComponent* APlayerCinematic::GetMeshByType(const EClothingSlotType SlotType) const { switch (SlotType) { case EClothingSlotType::Nipples: return NipplesMeshComponent; case EClothingSlotType::Anal: return AnalMeshComponent; case EClothingSlotType::Vagina: return VaginaMeshComponent; case EClothingSlotType::Head: return HeadMeshComponent; case EClothingSlotType::Neck: return NeckMeshComponent; case EClothingSlotType::Face: return FaceMeshComponent; case EClothingSlotType::Eyes: return EyesMeshComponent; case EClothingSlotType::Bodysuit: return BodyMeshComponent; case EClothingSlotType::Top: return TopMeshComponent; case EClothingSlotType::Bottom: return BottomMeshComponent; case EClothingSlotType::UnderwearTop: return BraMeshComponent; case EClothingSlotType::UnderwearBottom: return PantiesMeshComponent; case EClothingSlotType::Socks: return SocksMeshComponent; case EClothingSlotType::Footwear: return ShoesMeshComponent; default: return NipplesMeshComponent; } } void APlayerCinematic::EquipClothing(const UClothingItemInstance* ClothingItemInstance) { USkeletalMeshComponent* MeshComponent = GetMeshByType(ClothingItemInstance->GetClothingItem()->SlotType); MeshComponent->SetSkeletalMesh(ClothingItemInstance->GetClothingItem()->SkeletalMesh); if (ClothingItemInstance->GetClothingItem()->UseLeaderPose) { MeshComponent->SetLeaderPoseComponent(GetMesh()); } if (!ClothingItemInstance->GetClothingItem()->Materials.IsEmpty()) { for (const TPair& Material : ClothingItemInstance->GetClothingItem()->Materials) { MeshComponent->SetMaterialByName(Material.Key, Material.Value); } } } void APlayerCinematic::UnequipClothing(const UClothingItemInstance* ClothingItemInstance) { USkeletalMeshComponent* MeshComponent = GetMeshByType(ClothingItemInstance->GetClothingItem()->SlotType); MeshComponent->SetSkeletalMesh(nullptr); MeshComponent->SetLeaderPoseComponent(nullptr); }