Exemple #1
0
        public override void Unload()
        {
            ItemHold.Clear();

            try
            {
                Plugin.OnDisconnected();
            }
            catch
            {
            }

            TargetManager.Reset();

            // special case for wmap. this allow us to save settings
            UIManager.GetGump <WorldMapGump>()
            ?.SaveSettings();

            ProfileManager.Current?.Save
            (
                UIManager.Gumps.OfType <Gump>()
                .Where(s => s.CanBeSaved)
                .Reverse()
                .ToList()
            );

            Macros.Save();
            InfoBars.Save();
            ProfileManager.UnLoadProfile();

            StaticFilters.CleanCaveTextures();
            StaticFilters.CleanTreeTextures();

            NetClient.Socket.Disconnected -= SocketOnDisconnected;
            NetClient.Socket.Disconnect();
            _lightRenderTarget?.Dispose();
            _world_render_target?.Dispose();

            CommandManager.UnRegisterAll();
            Weather.Reset();
            UIManager.Clear();
            World.Clear();
            UOChatManager.Clear();
            DelayedObjectClickManager.Clear();

            _useItemQueue?.Clear();
            _useItemQueue = null;
            Hotkeys       = null;
            Macros        = null;
            MessageManager.MessageReceived -= ChatOnMessageReceived;


            Settings.GlobalSettings.WindowSize        = new Point(Client.Game.Window.ClientBounds.Width, Client.Game.Window.ClientBounds.Height);
            Settings.GlobalSettings.IsWindowMaximized = Client.Game.IsWindowMaximized();
            Client.Game.SetWindowBorderless(false);

            base.Unload();
        }