// Multiplayer By Caleb

#pragma once

#include "CoreMinimal.h"
#include "CCharacter.h"
#include "CPlayerCharacter.generated.h"

enum class ECAbilityInputID : uint8;
class UInputAction;
class UInputMappingContext;
class UCameraComponent;
class USpringArmComponent;
struct FInputActionValue;

UCLASS()
class CRUNCH_API ACPlayerCharacter : public ACCharacter
{
	GENERATED_BODY()

public:
	ACPlayerCharacter();
	virtual void PawnClientRestart() override;

public:
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

private:
	UPROPERTY(VisibleDefaultsOnly, Category= "View")
	TObjectPtr<USpringArmComponent> CameraBoom;
	UPROPERTY(VisibleDefaultsOnly, Category= "View")
	TObjectPtr<UCameraComponent> ViewCamera;

	UPROPERTY(EditDefaultsOnly, Category= "View")
	FRotator RotationRate{FRotator(0.0f, 720.0f, 0.0f)};
	
	FVector GetLookRightDir() const;
	FVector GetLookFwdDir() const;
	FVector GetMoveFwdDir() const;

	/*************************************************************************************/
	//------------------------------ Input------------------------------------------------
	/*************************************************************************************/
	UPROPERTY(EditDefaultsOnly, Category= "Input")
	TObjectPtr<UInputMappingContext> GameplayMappingContext;
	UPROPERTY(EditDefaultsOnly, Category= "Input")
	TObjectPtr<UInputAction> JumpInputAction;
	UPROPERTY(EditDefaultsOnly, Category= "Input")
	TObjectPtr<UInputAction> LookInputAction;
	UPROPERTY(EditDefaultsOnly, Category= "Input")
	TObjectPtr<UInputAction> MoveInputAction;
	UPROPERTY(EditDefaultsOnly, Category= "Input")
	TMap<ECAbilityInputID, UInputAction*> GameplayAbilityInputActions;

	void HandleLookInput(const FInputActionValue& InputActionValue);
	void HandleMoveInput(const FInputActionValue& InputActionValue);
	void HandleAbilityInput(const FInputActionValue& InputActionValue, ECAbilityInputID AbilityInputID);
	/*************************************************************************************/
	//------------------------- Death && Respawn-------------------------------------------
	/*************************************************************************************/
	virtual void OnDead() override;
	virtual void OnRespawn() override;
};
