Remove some global state dependence in ActorInfo.

Instead on relying on the global Game.ModData.ObjectCreator, this is passed in via a parameter.
This commit is contained in:
RoosterDragon
2015-11-20 21:21:12 +00:00
committed by Oliver Brakmann
parent c7249e6fa6
commit 0caffa8196
4 changed files with 14 additions and 21 deletions

View File

@@ -22,24 +22,11 @@ namespace OpenRA
readonly Cache<Type, ConstructorInfo> ctorCache;
readonly Pair<Assembly, string>[] assemblies;
public ObjectCreator(Manifest manifest)
public ObjectCreator(IEnumerable<Assembly> sourceAssemblies)
{
typeCache = new Cache<string, Type>(FindType);
ctorCache = new Cache<Type, ConstructorInfo>(GetCtor);
// All the core namespaces
var asms = typeof(Game).Assembly.GetNamespaces() // Game
.Select(c => Pair.New(typeof(Game).Assembly, c))
.ToList();
// Namespaces from each mod assembly
foreach (var a in manifest.Assemblies)
{
var asm = Assembly.LoadFile(Platform.ResolvePath(a));
asms.AddRange(asm.GetNamespaces().Select(ns => Pair.New(asm, ns)));
}
assemblies = asms.ToArray();
assemblies = sourceAssemblies.SelectMany(asm => asm.GetNamespaces().Select(ns => Pair.New(asm, ns))).ToArray();
}
public static Action<string> MissingTypeAction =