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

#pragma once

#include "Characters/Components/ShootingComponent.h"
#include "Player/InteractionComponent.h"
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "ExoPlayerController.generated.h"

class AExoPlayerCharacter;
class UInputMappingContext;
class UInputAction;
struct FInputActionValue;

UCLASS()
class EXO_API AExoPlayerController : public APlayerController
{
	GENERATED_BODY()

public:
	AExoPlayerController();

	virtual void BeginPlay() override;

	virtual void PlayerTick(float DeltaTime) override;

protected:
	virtual void SetupInputComponent() override;

	// Po prawej przypisane aktualnie klawisze
	UFUNCTION(BlueprintCallable, Category = "Input")
	void Move(const FInputActionValue& InputActionValue); // WSAD

	UFUNCTION(BlueprintCallable, Category = "Input")
	void Look(const FInputActionValue& InputActionValue); // MouseXY

	UFUNCTION(BlueprintCallable, Category = "Input")
	void Interact(); // E

	UFUNCTION(BlueprintCallable, Category = "Input")
	void PlayerJump(); // Space

	UFUNCTION(BlueprintCallable, Category = "Input")
	void PlayerDodge(); // Left Alt

	UFUNCTION(BlueprintCallable, Category = "Input")
	void ResetDodge(); 

	UFUNCTION(BlueprintCallable, Category = "Input")
	void PlayerStartCrouch(); // LCtrl\C\X

	UFUNCTION(BlueprintCallable, Category = "Input")
	void PlayerStopCrouch(); // LCtrl\C\X

	UFUNCTION(BlueprintCallable, Category = "Input")
	void PlayerStartSprint(); // LShift(Hold)

	UFUNCTION(BlueprintCallable, Category = "Input")
	void PlayerStopSprint();

	UFUNCTION(BlueprintCallable, Category = "Input")
	void PlayerShoot(); // LPM

	UFUNCTION(BlueprintCallable, Category = "Input")
	void PlayerAim(); // PPM - nieprzypisane
	
	UFUNCTION(BlueprintCallable, Category = "Input")
	void PlayerMeleAttack(); // V - nieprzypisane

	UFUNCTION(BlueprintCallable, Category = "Input")
	void PlayerChangeWeapon(); // MouseScroll

	UFUNCTION(BlueprintCallable, Category = "Input")
	void PlayerSelectFirstWeapon(); // 1

	UFUNCTION(BlueprintCallable, Category = "Input")
	void PlayerSelectSecondWeapon(); // 2
	
	UFUNCTION(BlueprintCallable, Category = "Input")
	void PlayerDropWeapon(); // F

	UFUNCTION(BlueprintCallable, Category = "Input")
	void PlayerReload(); // R


protected:
	UPROPERTY(EditAnywhere, Category = "Input")
	TObjectPtr<UInputMappingContext> InputContext;
	
	UPROPERTY(EditAnywhere, Category= "Input")
	TObjectPtr<UInputAction> MoveAction;

	UPROPERTY(EditAnywhere, Category = "Input")
	TObjectPtr<UInputAction> InteractAction;
	
	UPROPERTY(EditAnywhere, Category = "Input")
	TObjectPtr<UInputAction> LookAction;

	UPROPERTY(EditAnywhere, Category = "Input")
	TObjectPtr<UInputAction> JumpAction;

	UPROPERTY(EditAnywhere, Category = "Input")
	TObjectPtr<UInputAction> SprintAction;
	
	UPROPERTY(EditAnywhere, Category = "Input")
	TObjectPtr<UInputAction> CrouchAction;

	UPROPERTY(EditAnywhere, Category = "Input")
	TObjectPtr<UInputAction> DodgeAction;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Dodge Properties")
	FTimerHandle DodgeCooldownTimer;

	UPROPERTY(EditAnywhere, Category = "Dodge Properties")
	bool CanDodge = true;
	
	UPROPERTY(EditAnywhere, Category = "Input")
	TObjectPtr<UInputAction> ShootAction;

	UPROPERTY(EditAnywhere, Category = "Input")
	TObjectPtr<UInputAction> ReloadAction;

	UPROPERTY(EditAnywhere, Category = "Input")
	TObjectPtr<UInputAction> AimAction;
	
	UPROPERTY(EditAnywhere, Category = "Input")
	TObjectPtr<UInputAction> MeleAction;

	UPROPERTY(EditAnywhere, Category = "Input")
	TObjectPtr<UInputAction> ChangeWeaponAction;

	UPROPERTY(EditAnywhere, Category = "Input")
	TObjectPtr<UInputAction> SelectFirstWeaponAction;

	UPROPERTY(EditAnywhere, Category = "Input")
	TObjectPtr<UInputAction> SelectSecondWeaponAction;

	UPROPERTY(EditAnywhere, Category = "Input")
	TObjectPtr<UInputAction> DropWeaponAction;
	
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character")
	TObjectPtr<AExoPlayerCharacter> PlayerCharacter;

private:
	UInteractionComponent* InteractionComponent;

	UShootingComponent* ShootingComponent;
};
