using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.InputManagement;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using UnityEngine;

namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Input
{
    public class MoveDirectionByInputSystem : IInitializableSystem, IUpdatableSystem
    {
        private readonly IPlayerInput _playerInput;
        
        private ReactiveVariable<Vector3> _moveDirection;

        public MoveDirectionByInputSystem(IPlayerInput playerInput)
        {
            _playerInput = playerInput;
        }

        public void OnInit(Entity entity)
        {
            _moveDirection = entity.MoveDirection;
        }

        public void OnUpdate(float deltaTime)
        {
            _moveDirection.Value = new Vector3(_playerInput.Move.Value.x, 0, _playerInput.Move.Value.y);
        }
    }
}