// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "MyCharacter.generated.h"

UCLASS()
class LONESE_API AMyCharacter : public ACharacter
{
	GENERATED_BODY()

public:
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
	class UInputMappingContext* DefaultMapping;
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
	class UInputAction* MoveAction;
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
	class UInputAction* RunAction;
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
	class UInputAction* CrouchAction;
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
	class UInputAction* CameraMoveAction;
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
	class UInputAction* CameraZoomAction;
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
	class UInputAction* CameraResetAction;
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
	class UInputAction* CameraRotateAction;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")
	class TSubclassOf<class ACameraPawn> CameraActorClass;

	UFUNCTION(BlueprintCallable, Category = "Move")
	void Move(const FInputActionValue& Value);
	UFUNCTION(BlueprintCallable, Category = "Move")
	void BeginRun(const FInputActionValue& Value);
	UFUNCTION(BlueprintCallable, Category = "Move")
	void StopRun(const FInputActionValue& Value);
	UFUNCTION(BlueprintCallable, Category = "Move")
	void BeginCrouch(const FInputActionValue& Value);
	UFUNCTION(BlueprintCallable, Category = "Move")
	void StopCrouch(const FInputActionValue& Value);

	UFUNCTION(BlueprintCallable, Category = "State")
	bool IsRunning() const { return bIsRunning; }
	UFUNCTION(BlueprintCallable, Category = "State")
	bool IsCrouching() const { return bIsCrouching; }

	// Sets default values for this character's properties
	AMyCharacter();

	// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

private:
	bool bIsRunning = false;
	bool bIsCrouching = false;

	UPROPERTY(VisibleInstanceOnly, Category = "Camera")
	class ACameraPawn* CameraActor;

	void CameraZoom(const FInputActionValue& Value);
	void CameraRotate(const FInputActionValue& Value);
	void CameraMove(const FInputActionValue& Value);
	void CameraReset(const FInputActionValue& Value);
};
