clean that up...

This commit is contained in:
Chris Forbes
2010-04-04 13:04:39 +12:00
parent 7ff04ee333
commit 3d0b0dc82b
2 changed files with 18 additions and 12 deletions

View File

@@ -56,7 +56,7 @@ namespace OpenRA
static bool changePending;
public static Pair<Assembly, string>[] ModAssemblies;
public static void LoadModPackages(Manifest manifest)
static void LoadModPackages(Manifest manifest)
{
FileSystem.UnmountAll();
Timer.Time("reset: {0}");
@@ -67,7 +67,7 @@ namespace OpenRA
Timer.Time("mount temporary packages: {0}");
}
internal static void LoadModAssemblies(Manifest m)
static void LoadModAssemblies(Manifest m)
{
// All the core namespaces
var asms = typeof(Game).Assembly.GetNamespaces()
@@ -96,6 +96,19 @@ namespace OpenRA
ModAssemblies = asms.ToArray();
}
public static T CreateObject<T>(string classname)
{
foreach (var mod in ModAssemblies)
{
var fullTypeName = mod.Second + "." + classname;
var obj = mod.First.CreateInstance(fullTypeName);
if (obj != null)
return (T)obj;
}
throw new InvalidOperationException("Cannot locate type: {0}".F(classname));
}
public static void ChangeMap(string mapName)
{