// Fill out your copyright notice in the Description page of Project Settings. #include "PlayerCinematic.h" #include "NakedDesireCharacter.h" #include "Kismet/GameplayStatics.h" #include "NakedDesire/Clothing/ClothingItemData.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 UClothingItemData* ClothingItemData : Player->ClothingManager->GetEquippedClothing()) { EquipClothing(ClothingItemData); } } void APlayerCinematic::OnClothingEquip(const UClothingItemData* ClothingData) { EquipClothing(ClothingData); } void APlayerCinematic::OnClothingUnequip(const UClothingItemData* ClothingData) { UnequipClothing(ClothingData); } 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::Body: return BodyMeshComponent; case EClothingSlotType::Top: return TopMeshComponent; case EClothingSlotType::Bottom: return BottomMeshComponent; case EClothingSlotType::Bra: return BraMeshComponent; case EClothingSlotType::Panties: return PantiesMeshComponent; case EClothingSlotType::Socks: return SocksMeshComponent; case EClothingSlotType::Shoes: return ShoesMeshComponent; default: return NipplesMeshComponent; } } void APlayerCinematic::EquipClothing(const UClothingItemData* ClothingData) { USkeletalMeshComponent* MeshComponent = GetMeshByType(ClothingData->Info->SlotType); MeshComponent->SetSkeletalMesh(ClothingData->Info->SkeletalMesh); if (ClothingData->Info->UseLeaderPose) { MeshComponent->SetLeaderPoseComponent(GetMesh()); } if (!ClothingData->Info->Materials.IsEmpty()) { for (const TPair& Material : ClothingData->Info->Materials) { MeshComponent->SetMaterialByName(Material.Key, Material.Value); } } } void APlayerCinematic::UnequipClothing(const UClothingItemData* ClothingData) { USkeletalMeshComponent* MeshComponent = GetMeshByType(ClothingData->Info->SlotType); MeshComponent->SetSkeletalMesh(nullptr); MeshComponent->SetLeaderPoseComponent(nullptr); }