// (C) MAI 2020. All rights reserved.

#pragma once

#include "GameFramework/Actor.h"
#include "Components/SkeletalMeshComponent.h"

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "MotionControllerComponent.h"

#include "BaseMotionController.generated.h"

class AInverseWorldPawn;
class AMotionControllerSubActor;
class AControllerHint;

/**
 * Base class for motion controllers in BodyMap.
 */
UCLASS(Abstract)
class ABaseMotionController : public AActor
{
	GENERATED_BODY()
public:
	// Sets default values for this actor's properties
	ABaseMotionController();

	FVector GetControllerLocation();

	FRotator GetControllerRotation();

	/// If true, this controller should go into the right hand.
	UPROPERTY(EditAnywhere)
	bool bIsInRightHand = true;

	/// The motion controller component used to drive this MotionController.
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "BaseMotionController|Component")
	UMotionControllerComponent* MotionControllerComponent = nullptr;

	/// Skeletal mesh of the controller.
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "BaseMotionController|Component")
	USkeletalMeshComponent* ControllerSkeletalMeshComponent = nullptr;

	/// Sets up this controller's actions to the provided InputComponent.
	virtual void SetupInput(UInputComponent* InInputComponent);

	/// True if the controller grip is pressed.
	bool bIsGripPressed = false;

	virtual bool IsMovingWorld()
	{
		return bIsGripPressed;
	};

	/// IMotionControllerHandler interface begin :

	virtual void OnGripPressed()
	{
		bIsGripPressed = true;
	};

	virtual void OnGripReleased()
	{
		bIsGripPressed = false;
	};

	virtual void ScaleMesh(const float InScaleChangeRatio);

	virtual void ResetMeshScale();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
};
