internal static void StartGame(string mapUID, bool isShellmap) { BeforeGameStart(); var map = modData.PrepareMap(mapUID); viewport = new Viewport(new int2(Renderer.Resolution), map.Bounds, Renderer); orderManager.world = new World(modData.Manifest, map, orderManager, isShellmap); worldRenderer = new WorldRenderer(orderManager.world); if (orderManager.GameStarted) { return; } Ui.SelectedWidget = null; orderManager.LocalFrameNumber = 0; orderManager.LastTickTime = Environment.TickCount; orderManager.StartGame(); worldRenderer.RefreshPalette(); if (!isShellmap) { Sound.PlayNotification(null, "Speech", "StartGame", null); } }
internal static void StartGame(string mapUID, bool isShellmap) { BeforeGameStart(); Map map; using (new PerfTimer("PrepareMap")) map = modData.PrepareMap(mapUID); using (new PerfTimer("NewWorld")) { orderManager.world = new World(map, orderManager, isShellmap); orderManager.world.Timestep = Timestep; } worldRenderer = new WorldRenderer(orderManager.world); using (new PerfTimer("LoadComplete")) orderManager.world.LoadComplete(worldRenderer); if (orderManager.GameStarted) { return; } Ui.MouseFocusWidget = null; Ui.KeyboardFocusWidget = null; orderManager.LocalFrameNumber = 0; orderManager.LastTickTime = Environment.TickCount; orderManager.StartGame(); worldRenderer.RefreshPalette(); GC.Collect(); }
internal static void StartGame(string mapUID, bool isShellmap) { BeforeGameStart(); var map = modData.PrepareMap(mapUID); orderManager.world = new World(modData.Manifest, map, orderManager, isShellmap); worldRenderer = new WorldRenderer(orderManager.world); orderManager.world.LoadComplete(worldRenderer); if (orderManager.GameStarted) { return; } Ui.MouseFocusWidget = null; Ui.KeyboardFocusWidget = null; orderManager.LocalFrameNumber = 0; orderManager.LastTickTime = Environment.TickCount; orderManager.StartGame(); worldRenderer.RefreshPalette(); if (!isShellmap) { Sound.PlayNotification(null, "Speech", "StartGame", null); } }
internal static void StartGame(string mapUID, WorldType type) { // Dispose of the old world before creating a new one. worldRenderer?.Dispose(); Cursor.SetCursor(null); BeforeGameStart(); Map map; using (new PerfTimer("PrepareMap")) map = ModData.PrepareMap(mapUID); using (new PerfTimer("NewWorld")) { OrderManager.World = new World(ModData, map, OrderManager, type); OrderManager.FramesAhead = OrderManager.World.OrderLatency; } OrderManager.World.GameOver += FinishBenchmark; worldRenderer = new WorldRenderer(ModData, OrderManager.World); // Proactively collect memory during loading to reduce peak memory. GC.Collect(); using (new PerfTimer("LoadComplete")) OrderManager.World.LoadComplete(worldRenderer); // Proactively collect memory during loading to reduce peak memory. GC.Collect(); if (OrderManager.GameStarted) { return; } Ui.MouseFocusWidget = null; Ui.KeyboardFocusWidget = null; OrderManager.LocalFrameNumber = 0; OrderManager.LastTickTime = RunTime; OrderManager.StartGame(); worldRenderer.RefreshPalette(); Cursor.SetCursor(ChromeMetrics.Get <string>("DefaultCursor")); // Now loading is completed, now is the ideal time to run a GC and compact the LOH. // - All the temporary garbage created during loading can be collected. // - Live objects are likely to live for the length of the game or longer, // thus promoting them into a higher generation is not an issue. // - We can remove any fragmentation in the LOH caused by temporary loading garbage. // - A loading screen is visible, so a delay won't matter to the user. // Much better to clean up now then to drop frames during gameplay for GC pauses. GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; GC.Collect(); }
internal static void StartGame(string mapUID, WorldType type) { // Dispose of the old world before creating a new one. if (worldRenderer != null) { worldRenderer.Dispose(); } Cursor.SetCursor(null); BeforeGameStart(); Map map; using (new PerfTimer("PrepareMap")) map = ModData.PrepareMap(mapUID); using (new PerfTimer("NewWorld")) OrderManager.World = new World(ModData, map, OrderManager, type); OrderManager.World.GameOver += FinishBenchmark; worldRenderer = new WorldRenderer(ModData, OrderManager.World); GC.Collect(); using (new PerfTimer("LoadComplete")) OrderManager.World.LoadComplete(worldRenderer); // Create a Http server and start listening for incoming connections // Handle requests if (OrderManager.World.LocalPlayer != null && HttpServer.Listener == null) { HttpServer.Listener = new HttpListener(); HttpServer.Listener.Prefixes.Add(HttpServer.Url); HttpServer.Listener.Start(); Console.WriteLine("Listening for connections on {0}", HttpServer.Url); HttpServer.HandleIncomingConnections(); } GC.Collect(); if (OrderManager.GameStarted) { return; } Ui.MouseFocusWidget = null; Ui.KeyboardFocusWidget = null; OrderManager.LocalFrameNumber = 0; OrderManager.LastTickTime = RunTime; OrderManager.StartGame(); worldRenderer.RefreshPalette(); Cursor.SetCursor("default"); GC.Collect(); }
internal static void StartGame(string mapUID, WorldType type) { // Dispose of the old world before creating a new one. if (worldRenderer != null) { worldRenderer.Dispose(); } Cursor.SetCursor(null); BeforeGameStart(); Map map; using (new PerfTimer("PrepareMap")) map = ModData.PrepareMap(mapUID); using (new PerfTimer("NewWorld")) OrderManager.World = new World(ModData, map, OrderManager, type); ChromeProvider.World = OrderManager.World; // для доступа к текстурам из seq/*.yaml OrderManager.World.GameOver += FinishBenchmark; worldRenderer = new WorldRenderer(ModData, OrderManager.World); GC.Collect(); using (new PerfTimer("LoadComplete")) OrderManager.World.LoadComplete(worldRenderer); GC.Collect(); if (OrderManager.GameStarted) { return; } Ui.MouseFocusWidget = null; Ui.KeyboardFocusWidget = null; OrderManager.LocalFrameNumber = 0; OrderManager.LastTickTime = RunTime; OrderManager.StartGame(); worldRenderer.RefreshPalette(); Cursor.SetCursor("default"); GC.Collect(); }
internal static void StartGame(string mapUID, WorldType type) { // Dispose of the old world before creating a new one. if (worldRenderer != null) { worldRenderer.Dispose(); } BeforeGameStart(); Map map; using (new PerfTimer("PrepareMap")) map = ModData.PrepareMap(mapUID); using (new PerfTimer("NewWorld")) OrderManager.World = new World(ModData, map, OrderManager, type); worldRenderer = new WorldRenderer(ModData, OrderManager.World); GC.Collect(); using (new PerfTimer("LoadComplete")) OrderManager.World.LoadComplete(worldRenderer); GC.Collect(); if (OrderManager.GameStarted) { return; } Ui.MouseFocusWidget = null; Ui.KeyboardFocusWidget = null; OrderManager.LocalFrameNumber = 0; OrderManager.LastTickTime = RunTime; OrderManager.StartGame(); worldRenderer.RefreshPalette(); GC.Collect(); }
internal static void StartGame(string mapUID, WorldType type) { Cursor.SetCursor(null); BeforeGameStart(); Map map; using (new PerfTimer("PrepareMap")) map = ModData.PrepareMap(mapUID); using (new PerfTimer("NewWorld")) { OrderManager.World = new World(map, OrderManager, type); OrderManager.World.Timestep = Timestep; } if (worldRenderer != null) { worldRenderer.Dispose(); } worldRenderer = new WorldRenderer(OrderManager.World); using (new PerfTimer("LoadComplete")) OrderManager.World.LoadComplete(worldRenderer); if (OrderManager.GameStarted) { return; } Ui.MouseFocusWidget = null; Ui.KeyboardFocusWidget = null; OrderManager.LocalFrameNumber = 0; OrderManager.LastTickTime = RunTime; OrderManager.StartGame(); worldRenderer.RefreshPalette(); Cursor.SetCursor("default"); GC.Collect(); }