// © 2025 Naked People Team. All Rights Reserved. #include "EquipmentSlotMenuWidget.h" #include "Components/Button.h" #include "Kismet/GameplayStatics.h" #include "NakedDesire/Clothing/ClothingItemInstance.h" #include "NakedDesire/Clothing/ClothingManager.h" #include "NakedDesire/Inventory/InventorySubsystem.h" #include "NakedDesire/Player/NakedDesireCharacter.h" void UEquipmentSlotMenuWidget::Init(const EClothingSlotType InSlotType, const bool bInAtWardrobe) { SlotType = InSlotType; bAtWardrobe = bInAtWardrobe; } void UEquipmentSlotMenuWidget::NativeConstruct() { Super::NativeConstruct(); Player = Cast(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0)); RemoveClothingBtn->OnClicked.AddUniqueDynamic(this, &UEquipmentSlotMenuWidget::OnRemoveClothingClicked); } void UEquipmentSlotMenuWidget::OnRemoveClothingClicked() { if (Player && Player->ClothingManager) { if (bAtWardrobe) { // At the wardrobe the garment is stored, not dropped on the ground. if (UClothingItemInstance* Equipped = Player->ClothingManager->GetSlotClothing(SlotType)) { if (UInventorySubsystem* Inventory = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem()) Inventory->UnequipToWardrobe(Equipped); } } else { Player->ClothingManager->DropClothing(SlotType); } } OnActionPerformed.Broadcast(); }