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

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "Shotgun.generated.h"

UCLASS()
class GAMEJAMTEMPLATE_API AShotgun : public APawn
{
	GENERATED_BODY()

public:

	AShotgun();

	virtual void Tick(float DeltaTime) override;

	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

	/*
	* Get the hit result from the mouse click
	* @return The hit result
	*/
	FHitResult GetHitResult();

	/*
	* Triggered when the left mouse button is pressed
	*/
	void OnLeftMouseButtonEvent();

	/*
	* Triggered when the right mouse button is pressed
	*/
	void OnRightMouseButtonEvent();
	
	/*
	* Triggered when the right mouse button is pressed
	*/
	void OnNum1PressedButtonEvent();
	/*
	* Triggered when the right mouse button is pressed
	*/
	void OnNum2PressedButtonEvent();
	/*
	* Triggered when the right mouse button is pressed
	*/
	void OnNum3PressedButtonEvent();

	// Reload function
	void Reload(class AAmmo* NewPair);

	// Shooting function
	void Shoot(bool IsLeftRound);

protected:
	
	virtual void BeginPlay() override;

private: 
	/*
	* The pointer to the pawn's player controller
	*/
	class APlayerController* PlayerController;

	// The name of the object fetched by the UObjectBaseUtility::GetName method
	const FString ShotgunName;

	// The paper flipbook component holding the sprites.
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
	class UPaperFlipbookComponent* PaperFlipbook;

	// The flipbook for the empty ammo
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "AmmoType", meta = (AllowPrivateAccess = "true"))
	class UPaperFlipbook* EmptyAmmo;
	// The flipbook for the empty spread ammo
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "AmmoType", meta = (AllowPrivateAccess = "true"))
	class UPaperFlipbook* EmptySpreadAmmo;

	// Current Round in barrels
	class AAmmo* AmmoRound;

	// Indicator if the left bullet is shot
	bool LeftRoundShot;

	// Indicator if the right bullet is shot
	bool RightRoundShot;

	// Ammo Spawner
	class AAmmoSpawner* LocalAmmoSpawner;

	// The camera component
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
	class UCameraComponent* CameraComponent;

	// A reference to the sound manager.
	class USoundManager* SoundManager;

	// The sound of the target being shot.
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Sounds", meta = (AllowPrivateAccess = "true"))
	class USoundCue* AmmoEmptySound;

	// The sound of the target being flipped.
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Sounds", meta = (AllowPrivateAccess = "true"))
	class USoundCue* TargetMissedSound;

	// A reference to the default game mode.
	class AJamGameMode* JamGameMode;
};
