using System.Collections.Generic;
using Godot;
using KarrotStarterTemplate.Common.CameraController;
using KarrotStarterTemplate.Common.CharacterMovement;

namespace KarrotStarterTemplate.Entities.Player;

public partial class Player : CharacterBody3D
{
	private CharacterMovementController _movementController;
    private CharacterCameraController _cameraController;
    private AnimationTree _animationTree;
    private PlayerStateMachine _stateMachine;
    
    private Vector2 _blendPosition;

	public override void _Ready()
	{
		_cameraController = GetNode<CharacterCameraController>("CameraController");
		_movementController = GetNode<CharacterMovementController>("MovementController");
		_animationTree = GetNode<AnimationTree>("AnimationTree");
		_stateMachine = GetNode<PlayerStateMachine>("PlayerStateMachine");
		
	}

	public override void _PhysicsProcess(double delta)
	{
		Vector2 inputDir =  Input.GetVector("move_left", "move_right", "move_forward", "move_back");
		_stateMachine.package.Add("move_direction", inputDir);
		_stateMachine.package.Add("run", Input.IsActionPressed("run"));
		_stateMachine.package.Add("roll", Input.IsActionJustPressed("roll"));
		
		// Variant v = _animationTree.GetAnimation("run");
		// if (Input.IsActionPressed("run"))
		// {
		// 	GD.Print("Add run");
		// 	_stateMachine.AddStateInputsAction("run");
		// }
	}
}