fix: file & type name mismatches fixed
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
using Engine.Core;
|
||||
|
||||
namespace Engine.Integration.MonoGame;
|
||||
|
||||
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 color) => new(color.R, color.G, color.B, color.A);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Color ToPreMultipliedColor(this ColorRGBA color)
|
||||
{
|
||||
float alphaMultiplier = color.A / 255f;
|
||||
return new((byte)(color.R * alphaMultiplier), (byte)(color.G * alphaMultiplier), (byte)(color.B * alphaMultiplier), color.A);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ColorRGBA ToColorRGBA(this Color color) => new(color.R, color.G, color.B, color.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 Vector3D ToVector3D(this Vector3 vector) => new(vector.X, vector.Y, vector.Z);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 ToVector3(this Vector3D vector) => new(vector.X, vector.Y, vector.Z);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix ToXnaMatrix(this Matrix4x4 m) => new(
|
||||
m.M11, m.M12, m.M13, m.M14,
|
||||
m.M21, m.M22, m.M23, m.M24,
|
||||
m.M31, m.M32, m.M33, m.M34,
|
||||
m.M41, m.M42, m.M43, m.M44
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x4 FromXnaMatrix(this Matrix m) => new(
|
||||
m.M11, m.M12, m.M13, m.M14,
|
||||
m.M21, m.M22, m.M23, m.M24,
|
||||
m.M31, m.M32, m.M33, m.M34,
|
||||
m.M41, m.M42, m.M43, m.M44
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Microsoft.Xna.Framework.Quaternion ToXnaQuaternion(this Core.Quaternion quaternion) => new(quaternion.X, quaternion.Y, quaternion.Z, quaternion.W);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Rectangle ToDisplayRectangle(this Rectangle rectangle, DisplayMode displayMode) => new()
|
||||
{
|
||||
X = rectangle.X,
|
||||
Y = displayMode.Height - rectangle.Y - rectangle.Height,
|
||||
Width = rectangle.Width,
|
||||
Height = rectangle.Height
|
||||
};
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Rectangle ToRectangle(this AABB2D aabb) => new()
|
||||
{
|
||||
X = (int)aabb.LowerBoundary.X,
|
||||
Y = (int)aabb.LowerBoundary.Y,
|
||||
Width = (int)(aabb.UpperBoundary.X - aabb.LowerBoundary.X),
|
||||
Height = (int)(aabb.UpperBoundary.Y - aabb.LowerBoundary.Y)
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user