monogame-moontools.ecs-temp.../MonoGameBlank2dStartKit/MonoGameBlank2dStartKit.Core/Components.cs

34 lines
958 B
C#

using System;
using System.Numerics;
using Microsoft.Xna.Framework.Graphics;
using MonoGameBlank2dStartKit.Core.Content;
namespace MonoGameBlank2dStartKit.Core;
public readonly record struct Position(Vector2 Vector2)
{
public Position(float x, float y) : this(new Vector2(x, y)) { }
}
public readonly record struct Velocity(Vector2 Vector2)
{
public Velocity(float x, float y) : this(new Vector2(x, y)) { }
}
public readonly record struct Mass(int Value);
public readonly record struct RotationSpeed(float Speed, float Amount = float.MaxValue, float Drag = 0)
{
}
public readonly record struct Rotation(float Value, Vector2 Origin)
{
public Rotation(float value, Texture2D texture) : this(value, CenterOfTexture(texture)) { }
private static Vector2 CenterOfTexture(Texture2D texture)
{
return new Vector2((float) texture.Width / 2, (float) texture.Height / 2);
}
}
public readonly record struct Image(ImageId ImageId);