I've decided to embark on an XNA moddable game project of a simple rogue style. For all purposes of this question, I'm going to not be using a scripting engine, but rather allow modders to directly compile assemblies that are loaded by the game at run time. I know about the security problems this may raise.
So in order to expose the moddable content, I have gone about creating a generic project in XNA called
MyModel. This contains a number of interfaces that all inherit from
IPlugin, such as
Then I've created another project called
MyRogueModel. This references
MyModel project, and holds interfaces such as
IInventorySystem. More rogue specific interfaces, but again, all interfaces in this project inherit from
Then finally, I've created another project called
MyRogueGame, that references both
MyRogueModel projects. This project will be the game that you run and play. Here I have put the actual implementation of the
RenderingSystem classes. This project will also scan the mods directory during run time and load any
IPlugins it finds using reflection and override anything it finds from the default. For example if it finds a new implementation of the
DungeonGenerator it will use that one instead.
Now my question is, in order to get this far, I have effectively 2 projects that contain nothing but interfaces... which seems a little... strange ? For people to create mods for the game, I would give them both the
MyRogueModel assemblies in which they would reference. I'm not sure whether this is the right way to do it, but my reasoning goes as follows :
If I write 1 input system, I can use it in any game I write.
If I create 3 rogue like games, and a modder writes 1 rendering system, that modder could use the rendering system for all 3 games, because it all comes from the
I come from a more web based C# role, so having empty interface projects doesn't seem wrong, its just something I haven't done before. Before I embark on something that might be crazy, I'd just like to know whether this is a foolish idea and whether there's a better (or established) design principle I should be following ?