Refactor censorship

This commit is contained in:
2026-05-29 22:27:32 +03:00
parent fbca5dd1c0
commit 69ec356f16
4 changed files with 170 additions and 78 deletions
@@ -0,0 +1,93 @@
// © 2025 Naked People Team. All Rights Reserved.
#include "CensorshipComponent.h"
#include "Components/StaticMeshComponent.h"
#include "NakedDesire/Clothing/BodyPart.h"
#include "NakedDesire/Clothing/ClothingManager.h"
#include "NakedDesire/Global/Constants.h"
#include "NakedDesire/Global/NakedDesireUserSettings.h"
UCensorshipComponent::UCensorshipComponent()
{
PrimaryComponentTick.bCanEverTick = false;
}
void UCensorshipComponent::Initialize(UClothingManager* InClothingManager,
UStaticMeshComponent* InBoobL, UStaticMeshComponent* InBoobR,
UStaticMeshComponent* InVagina, UStaticMeshComponent* InAnal)
{
ClothingManager = InClothingManager;
BoobLCensorship = InBoobL;
BoobRCensorship = InBoobR;
VaginaCensorship = InVagina;
AnalCensorship = InAnal;
if (ClothingManager)
{
ClothingManager->OnClothingEquip.AddUniqueDynamic(this, &UCensorshipComponent::HandleClothingChanged);
ClothingManager->OnClothingUnequip.AddUniqueDynamic(this, &UCensorshipComponent::HandleClothingChanged);
}
if (UNakedDesireUserSettings* Settings = UNakedDesireUserSettings::GetNakedDesireUserSettings())
{
Settings->OnSettingsChanged.AddUniqueDynamic(this, &UCensorshipComponent::HandleSettingsChanged);
}
RefreshCensorship();
}
void UCensorshipComponent::RefreshCensorship()
{
if (!ClothingManager)
return;
const bool bCensor = ShouldCensor();
SetBodyPartCensored(EBodyPart::Boobs, bCensor && ClothingManager->IsBodyPartExposed(EBodyPart::Boobs));
SetBodyPartCensored(EBodyPart::Genitals, bCensor && ClothingManager->IsBodyPartExposed(EBodyPart::Genitals));
SetBodyPartCensored(EBodyPart::Ass, bCensor && ClothingManager->IsBodyPartExposed(EBodyPart::Ass));
}
void UCensorshipComponent::HandleClothingChanged(UClothingItemInstance* ClothingItemInstance)
{
RefreshCensorship();
}
void UCensorshipComponent::HandleSettingsChanged(UNakedDesireUserSettings* Settings)
{
RefreshCensorship();
}
bool UCensorshipComponent::ShouldCensor() const
{
if (IS_DEMO)
return true;
const UNakedDesireUserSettings* Settings = UNakedDesireUserSettings::GetNakedDesireUserSettings();
return Settings && Settings->GetIsCensorshipEnabled();
}
void UCensorshipComponent::SetBodyPartCensored(EBodyPart BodyPart, bool bCensored)
{
switch (BodyPart)
{
case EBodyPart::Boobs:
if (BoobLCensorship)
BoobLCensorship->SetVisibility(bCensored);
if (BoobRCensorship)
BoobRCensorship->SetVisibility(bCensored);
break;
case EBodyPart::Genitals:
if (VaginaCensorship)
VaginaCensorship->SetVisibility(bCensored);
break;
case EBodyPart::Ass:
if (AnalCensorship)
AnalCensorship->SetVisibility(bCensored);
break;
default:
break;
}
}
@@ -0,0 +1,66 @@
// © 2025 Naked People Team. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "CensorshipComponent.generated.h"
class UClothingManager;
class UClothingItemInstance;
class UNakedDesireUserSettings;
class UStaticMeshComponent;
enum class EBodyPart : uint8;
/**
* Owns the show/hide logic for the body-part censorship meshes. The meshes
* themselves stay on the character (BP-authored assets + fitted transforms);
* this component just drives their visibility from the equipped set + setting.
*/
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class NAKEDDESIRE_API UCensorshipComponent : public UActorComponent
{
GENERATED_BODY()
public:
UCensorshipComponent();
/**
* Wire dependencies and apply the initial censorship state. Call from the
* owning character's BeginPlay *after* Super::BeginPlay, so clothing
* hydration has already populated the equipped set.
*/
void Initialize(UClothingManager* InClothingManager,
UStaticMeshComponent* InBoobL, UStaticMeshComponent* InBoobR,
UStaticMeshComponent* InVagina, UStaticMeshComponent* InAnal);
/** Recompute every censor mesh from the current equipped set + setting. Idempotent. */
void RefreshCensorship();
private:
UFUNCTION()
void HandleClothingChanged(UClothingItemInstance* ClothingItemInstance);
UFUNCTION()
void HandleSettingsChanged(UNakedDesireUserSettings* Settings);
/** Censorship is forced on in the demo build regardless of the user setting. */
bool ShouldCensor() const;
void SetBodyPartCensored(EBodyPart BodyPart, bool bCensored);
UPROPERTY()
TObjectPtr<UClothingManager> ClothingManager;
UPROPERTY()
TObjectPtr<UStaticMeshComponent> BoobLCensorship;
UPROPERTY()
TObjectPtr<UStaticMeshComponent> BoobRCensorship;
UPROPERTY()
TObjectPtr<UStaticMeshComponent> VaginaCensorship;
UPROPERTY()
TObjectPtr<UStaticMeshComponent> AnalCensorship;
};