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

#pragma once

#include "CoreMinimal.h"
#include "DetourCrowdAIController.h"
#include "Perception/AIPerceptionTypes.h"
#include "NPCAIController.generated.h"

class ANakedDesireCharacter;

UCLASS()
class NAKEDDESIRE_API ANPCAIController : public ADetourCrowdAIController
{
	GENERATED_BODY()

	UPROPERTY()
	ANakedDesireCharacter* PlayerCharacter = nullptr;

	UPROPERTY(EditDefaultsOnly)
	UBehaviorTree* BehaviorTreeAsset = nullptr;

	bool bCurrentlyObserving = false;

public:
	ANPCAIController();

	// Clears any active observation of the player (used on un-possess and when the NPC is pooled out).
	void ClearObservation();
	void RunCustomBehaviorTree();

protected:
	UFUNCTION()
	void OnTargetPerceptionUpdate(AActor* Actor, FAIStimulus Stimulus);

	// Observation weight of the possessed NPC's type (§10.2), 1.0 if not an ANPC.
	float GetObservationWeight() const;

	virtual void OnPossess(APawn* InPawn) override;
	virtual void OnUnPossess() override;
};
