// © 2025 Naked People Team. All Rights Reserved. #include "ExposeBodyPartRestriction.h" #include "NakedDesire/Clothing/ClothingItemData.h" #include "NakedDesire/Player/NakedDesireCharacter.h" #include "NakedDesire/Clothing/ClothingManager.h" #define LOCTEXT_NAMESPACE "Missions.Restrictions.ExposeBodyPart" const FText RestrictionsExposeBodyPartDescription = LOCTEXT("Description", "Expose {BodyPart}"); #undef LOCTEXT_NAMESPACE void UExposeBodyPartRestriction::Init(ANakedDesireCharacter* PlayerCharacter) { Super::Init(PlayerCharacter); PlayerCharacter->ClothingManager->OnClothingEquip.AddUniqueDynamic(this, &UExposeBodyPartRestriction::EquipClothing); PlayerCharacter->ClothingManager->OnClothingUnequip.AddUniqueDynamic(this, &UExposeBodyPartRestriction::UnequipClothing); CheckClothing(); } void UExposeBodyPartRestriction::Stop() { Super::Stop(); Player->ClothingManager->OnClothingEquip.Remove(this, TEXT("ClothingEquip")); Player->ClothingManager->OnClothingUnequip.Remove(this, TEXT("ClothingUnequip")); } FText UExposeBodyPartRestriction::GetDescription() const { FText Part = UPrivateBodyPartType::GetString(BodyPart); return FText::Format(RestrictionsExposeBodyPartDescription, FFormatNamedArguments { {TEXT("BodyPart"), Part} }); } void UExposeBodyPartRestriction::EquipClothing(const UClothingItemData* ClothingData) { if (IsSuccess && ClothingData->Info->CoveredBodyParts.Contains(BodyPart)) { Init(Player); } } void UExposeBodyPartRestriction::UnequipClothing(const UClothingItemData* ClothingData) { if (IsSuccess) { return; } CheckClothing(); } void UExposeBodyPartRestriction::CheckClothing() { if (!Player || !Player->ClothingManager || Player->ClothingManager->ClothingSlots.IsEmpty()) { return; } const FClothingSlotData* TargetClothingItem = Player->ClothingManager->ClothingSlots.FindByPredicate([this](const FClothingSlotData& ClothingSlot) { if (ClothingSlot.ClothingData) { return ClothingSlot.ClothingData->Info->CoveredBodyParts.Contains(BodyPart); } return false; }); if (!TargetClothingItem) { Complete(); } }