Development Merge 2026.04.03 #8

Merged
Syntriax merged 51 commits from development into main 2026-04-03 14:08:02 +02:00
Showing only changes of commit fe0173b091 - Show all commits

View File

@@ -1,5 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.Xna.Framework.Graphics;
using Engine.Core; using Engine.Core;
namespace Engine.Integration.MonoGame; namespace Engine.Integration.MonoGame;
@@ -12,6 +14,7 @@ public class SpriteBatcher : Behaviour, IFirstFrameUpdate, IDraw
private ISpriteBatch spriteBatch = null!; private ISpriteBatch spriteBatch = null!;
private MonoGameCamera2D camera2D = null!; private MonoGameCamera2D camera2D = null!;
private readonly RasterizerState rasterizerState = new() { CullMode = CullMode.CullClockwiseFace };
private readonly ActiveBehaviourCollectorOrdered<int, IDrawableSprite> drawableSprites = new(GetPriority(), SortByPriority()); private readonly ActiveBehaviourCollectorOrdered<int, IDrawableSprite> drawableSprites = new(GetPriority(), SortByPriority());
public void FirstActiveFrame() public void FirstActiveFrame()
@@ -26,7 +29,13 @@ public class SpriteBatcher : Behaviour, IFirstFrameUpdate, IDraw
public void Draw() public void Draw()
{ {
spriteBatch.Begin(transformMatrix: camera2D.ViewMatrix.ToXnaMatrix()); Matrix4x4 transformMatrix = Matrix4x4.Identity
.ApplyTranslation(new Vector2D(camera2D.Viewport.X, camera2D.Viewport.Y) * .5f)
.ApplyScale(new Vector3D(1f, -1f, 1f))
.ApplyMatrix(camera2D.ViewMatrix)
.Transposed;
spriteBatch.Begin(transformMatrix: transformMatrix.ToXnaMatrix(), rasterizerState: rasterizerState);
for (int i = 0; i < drawableSprites.Count; i++) for (int i = 0; i < drawableSprites.Count; i++)
drawableSprites[i].Draw(spriteBatch); drawableSprites[i].Draw(spriteBatch);
spriteBatch.End(); spriteBatch.End();