using Godot;
using System;
using DungeonRPG.Scripts.General;

public partial class Player : CharacterBody3D
{
    [Export] public AnimatedSprite3D AnimatedSprite;
    
    [Export] public StateMachine StateMachine;
    
    public Vector2 Direction;
    public override void _Ready()
    {
    }
    public override void _PhysicsProcess(double delta)
    {
        Velocity = new Vector3(Direction.X, 0, Direction.Y);
        Velocity *= 5;
        MoveAndSlide();
    }

    public override void _Input(InputEvent @event)
    {
        Direction = Input.GetVector(
            GameConstants.INPUT_MOVE_LEFT,
            GameConstants.INPUT_MOVE_RIGHT,
            GameConstants.INPUT_MOVE_FORWARD,
            GameConstants.INPUT_MOVE_BACKWARD
        );

        if (Direction.X != 0)
        {
            AnimatedSprite.FlipH = Direction.X < 0;
        }

    }
}
