refactor: moved drawable triangles into systems project for platform agnosticism

This commit is contained in:
2026-01-27 13:04:04 +03:00
parent 7c9973a5e7
commit 985f898327
8 changed files with 60 additions and 67 deletions

View File

@@ -0,0 +1,29 @@
using System.Collections.Generic;
using Engine.Core;
namespace Engine.Systems.Graphics;
public class DrawableShape2D : 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 DrawableShape2D() => shape = Shape2D.Triangle;
public DrawableShape2D(Shape2D shape) => this.shape = shape;
public DrawableShape2D(Shape2D shape, ColorRGB color) { this.shape = shape; this.color = color; }
}