Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I making now engine for my game, it is based on component system ( every game object is a set of some components like: render, physics, ai etc ). I want to make my game extensible, i now how to make plugin system with .net but how to make game able to add at runtime new resurces from plugins ( like graphics, sounds, etc ) ? And how plugin that store content can look ? I want to make simple system like Total Annihilation have, to be able to add new units.

share|improve this question
1  
You might want to add what systems you are targeting (PC, 360, Phone7) since that has a big impact on what libraries you can use. –  coderanger Oct 27 '10 at 23:23
    
PC , and mayby xbox, but I don't know how plugin system can look on xbox, is it posible ? –  xnaCCCoder Oct 28 '10 at 8:07

1 Answer 1

You can create as many instances of ContentManager as you like. Just create a new instance for each plugin and set its root directory to something specific to that plugin.

For example, you could organise your plugin directory like this:

Plugins
|
+- TotallyCoolPlugin
   |
   +- TotallyCoolPlugin.dll
   |
   +- Content
      |
      +- TotallyCoolImage.xnb

Presumably your plugin will have some kind of plugin object that you can use reflection to find and instance. Tell it its base path, so then you can have it create a content manager (or something like this - it depends on your implementation). For example:

[PluginMainClass]
public class MyTotallyCoolPlugin : Plugin
{
    public override void LoadPlugin(string basePath)
    {
        ContentManager content = new ContentManager();
        content.RootDirectory = Path.Combine(basePath, @"Content");
    }
}

Once you have something like this working, you could expand it with other clever things. One possible example is to use ResourceContentManager to embed your content in the DLL itself. Read this and this.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.