49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
// © 2025 Naked People Team. All Rights Reserved.
|
|
|
|
|
|
#include "WearingSlotConstraint.h"
|
|
|
|
#include "NakedDesire/Clothing/ClothingManager.h"
|
|
#include "NakedDesire/Player/NakedDesireCharacter.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "Commissions.Constraints.WearingSlot"
|
|
|
|
void UWearingSlotConstraint::OnActivate()
|
|
{
|
|
if (Player && Player->ClothingManager)
|
|
{
|
|
Player->ClothingManager->OnClothingEquip.AddUniqueDynamic(this, &UWearingSlotConstraint::HandleClothingChanged);
|
|
Player->ClothingManager->OnClothingUnequip.AddUniqueDynamic(this, &UWearingSlotConstraint::HandleClothingChanged);
|
|
}
|
|
}
|
|
|
|
void UWearingSlotConstraint::OnDeactivate()
|
|
{
|
|
if (Player && Player->ClothingManager)
|
|
{
|
|
Player->ClothingManager->OnClothingEquip.RemoveDynamic(this, &UWearingSlotConstraint::HandleClothingChanged);
|
|
Player->ClothingManager->OnClothingUnequip.RemoveDynamic(this, &UWearingSlotConstraint::HandleClothingChanged);
|
|
}
|
|
}
|
|
|
|
bool UWearingSlotConstraint::IsMet() const
|
|
{
|
|
if (!Player || !Player->ClothingManager)
|
|
return false;
|
|
|
|
return Player->ClothingManager->IsClothingTypeOn(Slot) == bMustBeWorn;
|
|
}
|
|
|
|
void UWearingSlotConstraint::HandleClothingChanged(UClothingItemInstance* ClothingItemInstance)
|
|
{
|
|
NotifyChanged();
|
|
}
|
|
|
|
FText UWearingSlotConstraint::GetDescription() const
|
|
{
|
|
return bMustBeWorn
|
|
? LOCTEXT("Wearing", "while dressed in the required item")
|
|
: LOCTEXT("NotWearing", "while that slot is bare");
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE |