// © 2025 Naked People Team. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "NakedDesire/Interaction/Interactable.h"
#include "Bed.generated.h"

class UBoxComponent;
class UWidgetComponent;

/**
 * The apartment bed (GDD §2.4, §4.4 step 2, §11.19). Interacting sleeps: fast-forwards
 * 8 hours, restores energy, charges the phone, autosaves (all via UTimeOfDaySubsystem),
 * and loses any clothing left outside the apartment. Sleep is the only place the player
 * sleeps — there is no sleeping outside.
 */
UCLASS(Blueprintable)
class NAKEDDESIRE_API ABed : public AActor, public IInteractable
{
	GENERATED_BODY()

public:
	ABed();

	virtual void Interact_Implementation(ANakedDesireCharacter* Player) override;
	virtual bool CanInteract_Implementation(ANakedDesireCharacter* Player) const override;
	virtual FText GetInteractionPrompt_Implementation() const override;
	virtual void HideInteractionHint_Implementation() override;
	virtual void ShowInteractionFocusHint_Implementation() override;
	virtual void ShowInteractionProximityHint_Implementation() override;

protected:
	virtual void BeginPlay() override;

	// Cosmetic fade / SFX over the (instantaneous) time jump — authored in BP. Fired just
	// before the sleep is resolved so the screen can be covered as time advances.
	UFUNCTION(BlueprintImplementableEvent, Category = "Sleep")
	void PlaySleepTransition();

private:
	// Performs the actual sleep transaction (time skip + energy + loss). Split out so a BP
	// fade timeline can drive it at the black midpoint if desired.
	void DoSleep();

	void ApplyOutline(bool bEnabled, int32 StencilValue);
	
	UPROPERTY(EditDefaultsOnly)
	TObjectPtr<UStaticMeshComponent> MeshComponent;

	UPROPERTY(EditDefaultsOnly)
	TObjectPtr<UBoxComponent> ColliderComponent;

	UPROPERTY(EditDefaultsOnly)
	TObjectPtr<UWidgetComponent> InteractionHint;
};