#pragma once

#include "CoreMinimal.h"
#include "Engine/HitResult.h"
#include "GameFramework/PlayerController.h"
#include "PlayerControllerBase.generated.h"

UCLASS(BlueprintType, Blueprintable)
class INTEGRATION_API AlxPlayerControllerBase : public APlayerController
{
	GENERATED_BODY()

public:
	UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
	static void SetLookAt(const UObject *Context, const FHitResult &HitResult);

	UFUNCTION(BlueprintPure, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
	static const FHitResult &GetLookAt(const UObject *Context);

	UFUNCTION(BlueprintPure, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
	static const AActor *GetLookAtActor(const UObject *Context);

	UFUNCTION(BlueprintPure, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
	static FVector2D GetLookAtPixel(const UObject *Context);

	UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
	static void SetLookAtChanged(const UObject *Context);

	// Blueprint events
	UFUNCTION(BlueprintImplementableEvent, Category = "Luprex|Look-At Detection")
	void CalculateLookAt();

	UFUNCTION(BlueprintImplementableEvent, Category = "Luprex|Look-At Detection")
	void LookAtChanged();

	// Called by GameMode each tick.
	void UpdateLookAt();

	// Get the player controller, cast to AlxPlayerControllerBase.
	static AlxPlayerControllerBase *FromContext(const UObject *Context);

	UPROPERTY()
	FHitResult CurrentLookAt;

	bool MustCallLookAtChanged = false;
};
