feat: ISpriteBatch added for MonoGame integration

This commit is contained in:
2025-06-03 23:38:25 +03:00
parent 9edf3b0aa6
commit 24d1a1d764
5 changed files with 114 additions and 7 deletions

View File

@@ -13,18 +13,25 @@ public static class EngineConverterExtensions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static UniverseTime ToEngineTime(this GameTime gameTime) => new(gameTime.TotalGameTime, gameTime.ElapsedGameTime);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector2D ToVector2D(this Vector2 vector) => new(vector.X, vector.Y);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Color ToColor(this ColorRGBA rgba) => new(rgba.R, rgba.G, rgba.B, rgba.A);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector2D ToVector2D(this Point point) => new(point.X, point.Y);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector2 ToVector2(this Vector2D vector) => new(vector.X, vector.Y);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector2 ToDisplayVector2(this Vector2D vector) => vector.Scale(screenScale).ToVector2();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector2D ApplyDisplayScale(this Vector2D vector) => vector.Scale(screenScale);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Rectangle ToDisplayRectangle(this Rectangle rectangle, DisplayMode displayMode) => new()
{
@@ -33,4 +40,13 @@ public static class EngineConverterExtensions
Width = rectangle.Width,
Height = rectangle.Height
};
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Rectangle ToRectangle(this AABB aabb) => new()
{
X = (int)(aabb.LowerBoundary.X * screenScale.X),
Y = (int)(aabb.LowerBoundary.Y * screenScale.Y),
Width = (int)(aabb.UpperBoundary.X - aabb.LowerBoundary.X),
Height = (int)(aabb.UpperBoundary.Y - aabb.LowerBoundary.Y)
};
}