using System; namespace MoonWorks.Collision.Fixed { public class Collider : IHasAABB2D where T : struct, IShape2D { private readonly T[] Shapes; public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(Shapes).GetEnumerator(); public AABB2D AABB { get; } public Collider(T shape) { Shapes = new T[1] { shape }; AABB = shape.AABB; } public Collider(T[] shapes) { Shapes = new T[shapes.Length]; Array.Copy(shapes, Shapes, shapes.Length); var aabb = new AABB2D(); foreach (var shape in Shapes) { aabb = aabb.Compose(shape.AABB); } AABB = aabb; } } }