示例#1
0
        internal static void Dispose(object sender, EventArgs args)
        {
            Audio.Unload(); // This exists but never gets called by the vanilla game.

            if (_DetourModManager != null)
            {
                foreach (Assembly asm in _DetourOwners)
                {
                    _DetourModManager.Unload(asm);
                }

                _DetourModManager.Dispose();
                _DetourModManager = null;
                _DetourOwners.Clear();
            }
        }
示例#2
0
        internal static void RemoveAll(Mod mod)
        {
            if (mod is ModLoaderMod)
            {
                return;
            }

            int hooks = 0, detours = 0, ndetours = 0;

            bool OnHookUndo(object obj)
            {
                hooks++;
                return(true);
            }

            bool OnDetourUndo(object obj)
            {
                detours++;
                return(true);
            }

            bool OnNativeDetourUndo(object obj)
            {
                ndetours++;
                return(true);
            }

            Hook.OnUndo         += OnHookUndo;
            Detour.OnUndo       += OnDetourUndo;
            NativeDetour.OnUndo += OnNativeDetourUndo;

            foreach (var asm in AssemblyManager.GetModAssemblies(mod.Name))
            {
                manager.Unload(asm);
            }

            Hook.OnUndo         -= OnHookUndo;
            Detour.OnUndo       -= OnDetourUndo;
            NativeDetour.OnUndo -= OnNativeDetourUndo;

            if (hooks > 0 || detours > 0 || ndetours > 0)
            {
                Logging.tML.Debug($"Unloaded {hooks} hooks, {detours} detours and {ndetours} native detours from {mod.Name}");
            }
        }
 static void OnUnloadContent(Action <Mod> orig, Mod mod)
 {
     orig(mod);
     Manager.Unload(mod.Code);
 }