// Gravity Stomp Copyright Kevin Poretti

#pragma once

#include "CoreMinimal.h"
#include "Camera/CameraActor.h"
#include "GSCameraActor.generated.h"

/**
 * 
 */
UCLASS(showcategories=(Input))
class GRAVITYSTOMPGAME_API AGSCameraActor : public ACameraActor
{
	GENERATED_BODY()

public:
    UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Camera Settings")
	float PanSpeed;

	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Camera Settings")
	float ZoomSpeed;

	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Camera Settings")
	float MinZoom;

	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Camera Settings")
	float MaxZoom;

	UPROPERTY(BlueprintReadWrite)
	FVector2D PanDirection;

	UPROPERTY(BlueprintReadWrite)
	float ZoomDirection;

	AGSCameraActor();

protected:
	virtual void Tick(float DeltaSeconds) override;

private:
    FBox2D GetBoundingBoxFromViewportPercentage(float ScreenPercentage) const;

    FVector2D GetBoxCenter(FBox2D Box) const;

    void GetBoxDimensions(FBox2D Box, float& BoxHeight, float& BoxWidth) const;

	FVector GetWorldLocationFromScreenCoords(float InX, float InY) const;

	FVector2D ClampCameraLocationToStageBounds(FVector2D CameraLocation, FBox2D ScreenBox) const;

	float ClampZoom(float Zoom) const;
};
