Example #1
0
 public static void RunPhase(string phase)
 {
     try {
         // Make sure Init, Initialize, and *Mod phases are not repeated
         if (phase.StartsWith("Init") || phase.EndsWith("Mod"))
         {
             lock ( LoadedPhases ) {
                 if (LoadedPhases.Contains(phase))
                 {
                     return;
                 }
                 LoadedPhases.Add(phase);
                 // UnloadMod and ActionMod should not go through here!
                 if (phase == "UnloadMod" || phase == "ActionMod")
                 {
                     Log.Error(new ArgumentException(phase));
                     return;
                 }
             }
         }
         LastPhase = phase;
         if (!ModLoader.ModsInPhase.TryGetValue(phase.ToLowerInvariant(), out List <ModEntry> list))
         {
             Log.Verbo("Phase {0} skipped, no mods.", phase);
             return;
         }
         Log.Info("PHASE {0}", phase);
         foreach (var mod in list)
         {
             lock (mod.Metadata);
             if (mod.Metadata.Dlls != null)
             {
                 foreach (var dll in mod.Metadata.Dlls)
                 {
                     RunPhaseOnDll(mod, dll, phase);
                 }
             }
             if (mod.Metadata.Actions != null)
             {
                 ModActions.RunActions(mod, phase);
             }
         }
         Log.Verbo("Phase {0} ended", phase);
         Log.Flush();
     } catch (Exception ex) { Log.Error(ex); }
 }
Example #2
0
 public static void LoadMods(string phase)
 {
     try {
         if (!phase.EndsWith("OnShow"))
         {
             lock ( LoadedPhases ) {
                 if (LoadedPhases.Contains(phase))
                 {
                     return;
                 }
                 LoadedPhases.Add(phase);
             }
         }
         if (!ModScanner.ModsInPhase.TryGetValue(phase.ToLowerInvariant(), out List <ModEntry> list))
         {
             Log.Verbo("Phase {0} skipped, no mods.", phase);
             return;
         }
         Log.Info("PHASE {0}", phase);
         foreach (var mod in list)
         {
             lock (mod.Metadata);
             if (mod.Metadata.Dlls != null)
             {
                 foreach (var dll in mod.Metadata.Dlls)
                 {
                     RunPhaseOnDll(mod, dll, phase);
                 }
             }
             if (mod.Metadata.Actions != null)
             {
                 ModActions.RunActions(mod, phase);
             }
         }
         Log.Verbo("Phase {0} ended", phase);
         Log.Flush();
     } catch (Exception ex) { Log.Error(ex); }
 }