private void ProcessMod(IMod mod)
 {
     if (processedMods.Contains(mod))
     {
         return;
     }
     if (currentlyProcessing.Contains(mod))
     {
         throw new InvalidOperationException("Can't process mod [" + mod.Name + "], already processing it. Circular dependency?");
     }
     currentlyProcessing.Add(mod);
     mod.Initialize_PreGeneration();
     if (mod.InitBefore.Count() > 0)
     {
         throw new NotImplementedException("Mod.InitAfter and Mod.InitBefore are not yet supported. Sorry.");
     }
     foreach (var dependency in mod.Dependencies)
     {
         ProcessMod(all_mods_to_process.Union(all_possible_dependencies).Single(depModInstance => depModInstance.GetType() == dependency.Type));
     }
     foreach (var change in mod.Modifications)
     {
         if (game_injector.AssemblyContainsType(change.TargetType))
         {
             game_injector.Inject_Modification(change);
         }
         else if (lib_injector.AssemblyContainsType(change.TargetType))
         {
             lib_injector.Inject_Modification(change);
         }
         else
         {
             throw new InvalidOperationException("Cannot change behavoir of type [" + change.TargetType + "]!");
         }
     }
     processedMods.Add(mod);
     currentlyProcessing.Remove(mod);
 }
Exemple #2
0
 private void ProcessMod(IMod mod)
 {
     if (processedMods.Contains(mod))
     {
         return;
     }
     if (currentlyProcessing.Contains(mod))
     {
         throw new InvalidOperationException("Can't process mod [" + mod.Name + "], already processing it. Circular dependency?");
     }
     currentlyProcessing.Add(mod);
     mod.Initialize_PreGeneration();
     if (mod.InitBefore.Count() > 0)
     {
         throw new NotImplementedException("Mod.InitAfter and Mod.InitBefore are not yet supported. Sorry.");
     }
     foreach (var dependency in mod.Dependencies)
     {
         ProcessMod(all_mods_to_process.Union(all_possible_dependencies).Single(depModInstance => depModInstance.GetType() == dependency.Type));
     }
     foreach (var change in mod.Modifications)
     {
         if (game_injector.AssemblyContainsType(change.TargetType))
         {
             game_injector.Inject_Modification(change);
         }
         else if (lib_injector.AssemblyContainsType(change.TargetType))
         {
             lib_injector.Inject_Modification(change);
         }
         else
         {
             throw new InvalidOperationException("Cannot change behavoir of type [" + change.TargetType + "]!");
         }
     }
     processedMods.Add(mod);
     currentlyProcessing.Remove(mod);
 }