// Project Sword & Gun Copyright © 2021 Kevin Poretti

#pragma once

#include "CoreMinimal.h"

#include "Camera/CameraComponent.h"
#include "Characters/SNGCharacterBase.h"
#include "Components/SNGStateMachineComponent.h"
#include "GameFramework/SpringArmComponent.h"

#include "SNGProtagonist.generated.h"

USTRUCT(BlueprintType)
struct FMeleeAttackData
{
	GENERATED_BODY()

	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Animation")
	UAnimMontage* AttackMontage;
};

/**
 * 
 */
UCLASS()
class SWORDNGUN_API ASNGProtagonist : public ASNGCharacterBase, public ISNGEventProcessorInterface
{
	GENERATED_BODY()

public:
	ASNGProtagonist();

	void MoveForward(float Value);

	void MoveRight(float Value);

	UFUNCTION(BlueprintCallable)
	void DoJump();

	UFUNCTION(BlueprintCallable)
	float Dash();

	UFUNCTION(BlueprintCallable)
	float MeleeAttack(FMeleeAttackData MeleeAttackData);

	/**
	 * The state machine will be handling most if not all of the states
	 * we simply wrap the state machine's push event implementation since most
	 * objects that will want to push events to the protagonist will have a reference
	 * to the protag itself rather than the protag's state machine
	 */ 
	UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
	bool PushEvent(FSNGEvent Event);
	
protected:
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
	UCameraComponent* CameraComponent;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
	USpringArmComponent* SpringArmComponent;
	
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
	USNGStateMachineComponent* StateMachineComponent;
	
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Animations")
	UAnimMontage* DashMontage;
	
	float LastForwardAxis;
	float LastRightAxis;
	
	FVector GetInputAsWorldDirection();

	FVector GetInputAsWorldDirection(float ForwardAxisValue, float RightAxisValue);

	virtual void Tick(float DeltaSeconds) override;
};
