public static void Unload() { Unloading = true; #if CLIENT Sound.OnGameEnd(); if (GameMain.LightManager != null) { GameMain.LightManager.ClearLights(); } #endif foreach (Submarine sub in loaded) { sub.Remove(); } loaded.Clear(); visibleEntities = null; if (GameMain.GameScreen.Cam != null) { GameMain.GameScreen.Cam.TargetPos = Vector2.Zero; } RemoveAll(); if (Item.ItemList.Count > 0) { List <Item> items = new List <Item>(Item.ItemList); foreach (Item item in items) { DebugConsole.ThrowError("Error while unloading submarines - item \"" + item.Name + "\" not removed"); try { item.Remove(); } catch (Exception e) { DebugConsole.ThrowError("Error while removing \"" + item.Name + "\"!", e); } } Item.ItemList.Clear(); } Ragdoll.RemoveAll(); PhysicsBody.RemoveAll(); GameMain.World.Clear(); Unloading = false; }