using System.Threading.Tasks;
using Godot;
using Playground.Common.CharacterMovement;

namespace KarrotStarterTemplate.Common.StateMachines.Custom.PlayerStateMachines;

public partial class MovementBasePlayerState : BasePlayerState
{
    // TODO
    [Export] public string animationBlendPositionPath { get; set; } = "parameters/LocomotionBlendspace/blend_position";
    [Export] public CharacterMovementMode movementMode { get; set; }


    protected override Task OnEnter()
    {
        characterMovement.SetMovementMode(movementMode);

        return base.OnEnter();
    }

    protected override void OnStateProcess(double delta)
    {
        base.OnStateProcess(delta);
        animationTree.Set(animationBlendPositionPath, characterMovement.blendspacePosition);
    }
    
    protected override void OnStatePhysicsProcess(double delta)
    {
        characterMovement.AddMovementInput(cameraController.camera.GlobalBasis.Z, package.GetVector3("move_direction").Y);
        characterMovement.AddMovementInput(cameraController.camera.GlobalBasis.X, package.GetVector3("move_direction").X);

        // TODO: ?
        // cameraController.rotatePlayer = !package.inputDirection.IsZeroApprox();
    }

}