// Copyright CodeSpartan, 2022. All rights reserved.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "PlayerControllerCpp.generated.h"

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnViewportResize);

UCLASS()
class MMOKITCODE_API APlayerControllerCpp : public APlayerController
{
	GENERATED_BODY()

public:

	APlayerControllerCpp(const FObjectInitializer& ObjectInitializer);

	virtual void BeginPlay() override;
	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;

	UFUNCTION(BlueprintImplementableEvent, Category = Game)
	void CustomPlayerStart();

	/** Performs a collision query under the mouse cursor, looking for object types, with ignore */
	UFUNCTION(BlueprintCallable, Category = "Game|Player", meta = (bTraceComplex = true))
	bool GetHitResultUnderCursorForObjectsWithIgnore(const TArray<TEnumAsByte<EObjectTypeQuery> >& ObjectTypes, bool bTraceComplex, const TArray<AActor*>& InIgnoreActors, FHitResult& HitResult) const;

	/** An event to bind to for when the viewport size changes. Useful for widgets that have a custom scale logic. */
	UPROPERTY(BlueprintAssignable)
	FOnViewportResize ViewportResizeEvent;

private:
	bool GetHitResultAtScreenPositionWithIgnore(const FVector2D ScreenPosition, const TArray<TEnumAsByte<EObjectTypeQuery> >& ObjectTypes, bool bTraceComplex, const TArray<AActor*>& InIgnoreActors, FHitResult& HitResult) const;
};
