// Oleg Petruny proprietary.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"

#include "Interactable/Interactable.h"

#include "PlayerBase.generated.h"

UCLASS()
class APlayerBase : public ACharacter
{
    GENERATED_BODY()

public:
    APlayerBase();

    virtual void Tick(float DeltaTime) override;
    virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

protected:
    virtual void BeginPlay() override;

    UFUNCTION(BlueprintCallable, Category = CameraMode)
    void SwitchToCameraPawn();

    UFUNCTION(BlueprintCallable, Category = Character)
    void MoveCamera(FVector2D value);
    UFUNCTION(BlueprintCallable, Category = Character)
    void MoveCharacter(FVector2D value);
    virtual void Jump() override;
    UFUNCTION(BlueprintCallable, Category = Character)
    void SwitchRun(bool run);

    UFUNCTION(BlueprintCallable, Category = Character)
    void UpdatePitch(float min, float max);

    UPROPERTY(EditDefaultsOnly)
    TSoftObjectPtr<class UInputMappingContext> inputMapping;

    UPROPERTY(EditAnywhere)
    float moveSpeed = 200;
    UPROPERTY(EditAnywhere)
    float runSpeedMultiplier = 4;

    UPROPERTY(EditAnywhere)
    bool moveLocked = false;
    UPROPERTY(EditAnywhere)
    bool jumpLocked = false;
    UPROPERTY(EditAnywhere)
    bool runLocked = false;
    UPROPERTY(EditAnywhere)
    bool interactionLocked = false;

    APlayerCameraManager* cameraManager;
    class UCameraComponent* camera;
    UPROPERTY(EditAnywhere)
    bool cameraLocked = false;
    UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
    float minPitch = -80;
    UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
    float maxPitch = 65;

private:
    void LoadInteractablesActivators();
    void InteractableActivated(AInteractable* interactable, EActivatorType type);
    void InteractableDeactivated(AInteractable* interactable, EActivatorType type);
};
