Engine-Pong/Shared/Behaviours/DrawableColliderShape.cs

27 lines
766 B
C#

using System.Collections.Generic;
using Syntriax.Engine.Core;
using Syntriax.Engine.Integration.MonoGame;
namespace Pong.Behaviours;
public class DrawableColliderShape : Syntriax.Engine.Physics2D.Collider2DShape, IDrawableTriangle
{
private readonly IList<Triangle> triangles = [];
public ColorRGBA Color { get; set; } = new ColorRGBA(255, 255, 255);
public void Draw(ITriangleBatch triangleBatch)
{
Recalculate();
ShapeWorld.ToTrianglesConvex(triangles);
foreach (Triangle triangle in triangles)
triangleBatch.Draw(triangle, Color);
}
public DrawableColliderShape(Shape2D shape) : base(shape) { }
public DrawableColliderShape(Shape2D shape, ColorRGBA color) : base(shape) { Color = color; }
}