Over the last year or so I’ve built a lot of code that would be great to release as a MonoGame extension library. Unfortunately, due to the way MonoGame is structured it makes it rather difficult.
Take for example this Sprite class:
public class Sprite
{
public TextureRegion TextureRegion { get; set; }
public Color Color { get; set; }
public Vector2 Origin { get; set; }
public SpriteEffects Effect { get; set; }
public float Depth { get; set; }
public float Rotation { get; set; }
public Vector2 Position { get; set; }
public Vector2 Scale { get; set; }
}
And the extension method on sprite batch that goes with it.
public static void Draw(this SpriteBatch spriteBatch, Sprite sprite);
The problem is that to build a reusable library with this class in it I need to reference MonoGame so I can get access to the Vector2, SpriteEffects and Color classes. This wouldn’t be a problem on it’s own, except that the library can only target a single platform meaning I have to build that library for Windows, Android, iOS, etc.
A better solution is to make this library into a Portable Class Library (PCL) but to do that I need it to reference the portable version of MonoGame.
http://www.monogame.net/2014/04/15/monogame-3-2-nuget-packages-are-go/
I’ve been doing this is my games and it works well, but since I’m targeting Android and the MonoGame portable libraries are not official and don’t have an Android project template for the NuGet yet I’m currently running my own build from source copy.
I know there’s been some discussion around how to improve the PCL version of MonoGame and I’m not sure if this has already been discussed but I wanted to propose a good first step.
I think it would be a good idea to split MonoGame up into a few different DLL’s similar to how XNA used to be structured perhaps. In particular, to get the base framework classes into a Portable Class Library (e.g. Vector2, Color, Matrix, Point, Rectangle).
Doing this would make it significantly more flexible to create new PCL’s for reuse across platforms. You could create a single compiled DLL and reference it from all of your platform projects without the need to recompile it every time.
If the MonoGame team is interested in this I’d be happy to create a fork on github and do the work to split it up. I just wanted to discuss it here first and gather thoughts on the idea.
Cheers