feat: Shape IEnumerable

This commit is contained in:
Syntriax 2024-01-24 12:50:26 +03:00
parent 468615e4cb
commit bfab35c27e
1 changed files with 5 additions and 1 deletions

View File

@ -1,11 +1,12 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Syntriax.Engine.Core;
namespace Syntriax.Engine.Physics2D.Primitives;
public record Shape(IList<Vector2D> Vertices)
public record Shape(IList<Vector2D> Vertices) : IEnumerable<Vector2D>
{
public Vector2D this[Index index] => Vertices[index];
@ -61,6 +62,9 @@ public record Shape(IList<Vector2D> Vertices)
return true;
}
public IEnumerator<Vector2D> GetEnumerator() => Vertices.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => Vertices.GetEnumerator();
}
public static class ShapeExtensions