예제 #1
0
        public override void Unload()
        {
            base.Unload();

            if (Storage != null)
            {
                using (Stream p = Storage?.GetStream("EmoteIDs.json", FileAccess.Write))
                    using (StreamWriter s = new StreamWriter(p))
                    {
                        s.Write(JsonConvert.SerializeObject(EmoticonHandler.convertingEmotes, Formatting.Indented));
                    }
            }

            if (Irc?.Connected ?? false)
            {
                Irc?.Disconnect();
            }
            Irc?.Dispose();
            Irc = null;
            OldConfig?.Load();
            OldConfig?.Dispose();
            OldConfig = null;
            Storage   = null;
            Store?.Dispose();
            Store = null;
            Textures?.Dispose();
            Textures               = null;
            RecentChatters         = null;
            WorldGen.SpawnTownNPC -= SpawnTownNpcHook;


            if (ModContent.GetInstance <EventWorld>() != null)
            {
                ModContent.GetInstance <EventWorld>().WorldScheduler = new Scheduler(Thread.CurrentThread,
                                                                                     new GameTickClock(ModContent.GetInstance <EventWorld>()));
                ModContent.GetInstance <EventWorld>().RealtimeScheduler = new Scheduler();
                ModContent.GetInstance <EventWorld>().CurrentEvent      = null;
            }

            Web      = null;
            Instance = null;
            EventsPool?.Clear();
            EventsPool = null;
            GlobalSpawnOverride.HandleCleanup();
            TwitchBoss.ClearPool();
            TwitchBoss.Boss = string.Empty;
        }