using UnityEngine;

namespace pdinklag
{
    public static class BoundsExtensions
    {
        public static InlineArray<Vector3> Corners(this Bounds b)
        {
            var points = new InlineArray<Vector3>(8);
            points[0] = b.min;
            points[1] = b.min + b.size.x * Vector3.right;
            points[2] = b.min + b.size.y * Vector3.up;
            points[3] = b.min + b.size.z * Vector3.forward;
            points[4] = b.max;
            points[5] = b.max - b.size.x * Vector3.right;
            points[6] = b.max - b.size.y * Vector3.up;
            points[7] = b.max - b.size.z * Vector3.forward;
            return points;
        }

        public static Bounds Scaled(this Bounds b, Vector3 scale)
        {
            var size = b.size;
            size.Scale(scale);
            return new(b.center, size);
        }

        public static Bounds Expanded(this Bounds b, Vector3 expand)
        {
            var result = b;
            result.Expand(expand);
            return result;
        }
        
        public static Bounds Expanded(this Bounds b, float expand)
        {
            var result = b;
            result.Expand(expand);
            return result;
        }
    }
}
