feat: basic MonoGame integration implementations added

This commit is contained in:
2025-06-01 15:02:25 +03:00
parent fe8bde855d
commit 2caa042317
14 changed files with 607 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
using System.Collections.Generic;
using Syntriax.Engine.Core;
namespace Syntriax.Engine.Integration.MonoGame;
public class DrawableShapeBehaviour : Behaviour2D, IDrawableTriangle, IPreDraw
{
private readonly Shape2D shape = new([]);
private readonly List<Triangle> worldTriangles = [];
private readonly Shape2D worldShape = new([]);
protected ColorRGB color = new(255, 255, 255);
public void PreDraw() => UpdateWorldShape();
public void Draw(ITriangleBatch triangleBatch)
{
worldShape.ToTrianglesConvex(worldTriangles);
foreach (Triangle triangle in worldTriangles)
triangleBatch.Draw(new(triangle.C, triangle.B, triangle.A), color);
}
protected void UpdateWorldShape() => shape.Transform(Transform, worldShape);
public DrawableShapeBehaviour() => shape = Shape2D.Triangle;
public DrawableShapeBehaviour(Shape2D shape) => this.shape = shape;
public DrawableShapeBehaviour(Shape2D shape, ColorRGB color) { this.shape = shape; this.color = color; }
}