// © 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;
};