using Intrepid.Utilities;
using UnityEngine;

namespace Intrepid.Core.Entities
{
    public class EntityMotorSmoothRotation : MonoBehaviour
    {
        [GroupConfigurations, SerializeField] private float turnSpeed = 1440f;

        public void TurnModel(Transform entityTransform, Vector3 desiredForward)
        {
            if (desiredForward.sqrMagnitude <= 0.0001f)
            {
                return;
            }
            entityTransform.rotation = Quaternion.RotateTowards(
                entityTransform.rotation,
                Quaternion.LookRotation(desiredForward, Vector3.up),
                turnSpeed * Time.deltaTime
            );
        }
    }
}