using UnityEngine;

namespace XGame.Database
{
    public static class VectorUtils
    {
        /// <summary>
        /// Vector3 -> Vec3 的倍数
        /// </summary>
        public static readonly int Multiple = 1000;
        #region Vec3
        /// <summary>
        /// 默认缩小1000倍
        /// </summary>
        /// <param name="vec"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        public static Vector3 ToVector3(this Vec3 vec, float scale = 0.001f)
        {
            var result = new Vector3(vec.X, vec.Y, vec.Z);
            return result * scale;
        }
        public static Vector3Int ToVector3Int(this Vec3 vec)
        {
            return new Vector3Int(vec.X, vec.Y, vec.Z);
        }
        #endregion
        #region Vec2
        /// <summary>
        /// 默认缩小1000倍
        /// </summary>
        /// <param name="vec"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        public static Vector2 ToVector2(this Vec2 vec, float scale = 0.001f)
        {
            var result = new Vector2(vec.X, vec.Y);
            return result * scale;
        }
        public static Vector2Int ToVector2Int(this Vec2 vec)
        {
            return new Vector2Int(vec.X, vec.Y);
        }
        #endregion
    }
}
