Beispiel #1
0
        /// <summary>
        /// Unregisters an already registered EverestModule (mod) dynamically. Invokes Unload.
        /// </summary>
        /// <param name="module"></param>
        internal static void Unregister(this EverestModule module)
        {
            module.Unload();

            Assembly asm = module.GetType().Assembly;

            MainThreadHelper.Do(() => _DetourModManager.Unload(asm));
            _RelinkedAssemblies.Remove(asm);

            // TODO: Unload from LuaLoader
            // TODO: Unload from EntityLoaders
            // TODO: Undo event listeners
            // TODO: Unload from registries
            // TODO: Make sure modules depending on this are unloaded as well.
            // TODO: Unload content, textures, audio, maps, AAAAAAAAAAAAAAAAAAAAAAA

            lock (_Modules) {
                int index = _Modules.IndexOf(module);
                _Modules.RemoveAt(index);
            }

            InvalidateInstallationHash();

            Logger.Log(LogLevel.Info, "core", $"Module {module.Metadata} unregistered.");
        }
Beispiel #2
0
        public MainThreadHelper(Game game)
            : base(game)
        {
            Instance = this;

            UpdateOrder = -500000;
            MainThread  = Thread.CurrentThread;
        }
Beispiel #3
0
            private static void LoadAutoUpdated(object source, FileSystemEventArgs e)
            {
                if (!AutoLoadNewMods)
                {
                    return;
                }

                Logger.Log(LogLevel.Info, "loader", $"Possible new mod container: {e.FullPath}");
                QueuedTaskHelper.Do("LoadAutoUpdated:" + e.FullPath, () => AssetReloadHelper.Do($"{Dialog.Clean("ASSETRELOADHELPER_LOADINGNEWMOD")} {Path.GetFileName(e.FullPath)}", () => MainThreadHelper.Do(() => {
                    if (Directory.Exists(e.FullPath))
                    {
                        LoadDir(e.FullPath);
                    }
                    else if (e.FullPath.EndsWith(".zip"))
                    {
                        LoadZip(e.FullPath);
                    }
                    ((patch_OuiMainMenu)(AssetReloadHelper.ReturnToScene as Overworld)?.GetUI <OuiMainMenu>())?.RebuildMainAndTitle();
                })));
            }