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

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "StatsManager.generated.h"

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FAttributeUpdateSignature, float, CurrentValue, float, MaxValue);


UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class NAKEDDESIRE_API UStatsManager : public UActorComponent
{
	GENERATED_BODY()

	float Embarrassment = 0.0f;
	float MaxEmbarrassment = 100.0f;
	float Energy = 1000.0f;
	float MaxEnergy = 1000.0f;

	int32 ObserverCount = 0;

public:
	UStatsManager();

	UPROPERTY(EditDefaultsOnly, Category = "Embarrassment")
	float EmbarrassmentGainRate = 10.0f;

	UPROPERTY(EditDefaultsOnly, Category = "Embarrassment")
	float EmbarrassmentDecayRate = 1.0f;

protected:
	virtual void BeginPlay() override;
	virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

public:
	float Stamina = 100.0f;
	float MaxStamina = 100.0f;

	// Called by NPCAIController when sight is gained or lost.
	// CoverageWeight: fraction of body covered [0..1]; pass 0.0f until #05 (GetEffectiveCoverage) lands.
	void SetObserved(bool bObserved, float CoverageWeight = 0.0f);

	UFUNCTION(BlueprintCallable)
	void IncreaseEmbarrassment(float Amount);
	void DecreaseEmbarrassment(float Amount);
	void DecreaseStamina(float Amount);
	void IncreaseStamina(float Amount);
	void DecreaseEnergy(float Amount);
	void RestoreEnergy();

	UPROPERTY(BlueprintAssignable)
	FAttributeUpdateSignature EmbarrassmentUpdate;
	
	UPROPERTY(BlueprintAssignable)
	FAttributeUpdateSignature StaminaUpdate;
	
	UPROPERTY(BlueprintAssignable)
	FAttributeUpdateSignature EnergyUpdate;
};
