Esempio n. 1
0
        public PulsarMod LoadMod(string assemblyPath)
        {
            if (!File.Exists(assemblyPath))
            {
                throw new IOException($"Couldn't find file: {assemblyPath}");
            }

            try
            {
                Assembly asm     = Assembly.LoadFile(assemblyPath);
                Type     modType = asm.GetTypes().FirstOrDefault(t => t.IsSubclassOf(typeof(PulsarMod)));

                if (modType != null)
                {
                    PulsarMod mod = Activator.CreateInstance(modType) as PulsarMod;
                    activeMods.Add(mod.Name, mod);
                    OnModSuccessfullyLoaded?.Invoke(mod.Name, mod);

                    Logger.Info($"Loaded mod: {mod.Name} Version {mod.Version} Author: {mod.Author}");
                    return(mod);
                }
                else
                {
                    Logger.Info($"Skipping {Path.GetFileName(assemblyPath)}; couldn't find mod entry point.");

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Info($"Failed to load mod: {Path.GetFileName(assemblyPath)}\n{e}");

                return(null);
            }
        }
Esempio n. 2
0
 internal void UnloadMod(PulsarMod mod, ref Harmony harmony)
 {
     activeMods.Remove(mod.Name);                 // Removes selected mod from activeMods
     harmony.UnpatchAll(mod.HarmonyIdentifier()); // Removes all patches from selected mod
     OnModUnloaded?.Invoke(mod);
     Logger.Info($"Unloaded mod: {mod.Name} Version {mod.Version} Author: {mod.Author}");
     GC.Collect();
 }
Esempio n. 3
0
        public string GetModName(string modName)
        {
            PulsarMod mod = ModManager.Instance.GetMod(modName);

            return($"{mod.Name} {mod.Version} MPF{mod.MPFunctionality}");
        }