// Allows the game to run logic such as updating the world, checking for collisions, gathering input, and playing audio. protected override void Update(GameTime gameTime) { if (m_debugFont == null) { return; } // Apply video mode changes. MyVideoModeManager.ApplyChanges(); // Update times in static member variables UpdateTimes(gameTime); //if (MyMinerGame.IsDeviceResetted) // MyVideoModeManager.UpdateAfterDeviceReset(); MyRender.GetRenderProfiler().StartProfilingBlock("Particles wait"); MyParticlesManager.WaitUntilUpdateCompleted(); MyRender.GetRenderProfiler().EndProfilingBlock(); MyRender.GetRenderProfiler().StartProfilingBlock("Receive Multiplayer Messages"); MyMultiplayerPeers.Static.Update(); MyRender.GetRenderProfiler().EndProfilingBlock(); int updateBlock = -1; MyRender.GetRenderProfiler().StartProfilingBlock("Update", ref updateBlock); if (MyMwcFinalBuildConstants.EnableLoggingInDrawAndUpdateAndGuiLoops == true) { MyMwcLog.WriteLine("MyMinerGame.Update() - START"); MyMwcLog.IncreaseIndent(); MyMwcLog.WriteLine("Update - gameTime.ElapsedGameTime: " + gameTime.ElapsedGameTime.ToString()); MyMwcLog.WriteLine("Update - gameTime.TotalGameTime: " + gameTime.TotalGameTime.ToString()); MyMwcLog.WriteLine("Max Garbage Generation: " + GC.MaxGeneration.ToString()); for (int i = 0; i <= GC.MaxGeneration; ++i) { MyMwcLog.WriteLine("Generation " + i.ToString() + ": " + GC.CollectionCount(i).ToString() + " collections"); } MyMwcLog.WriteLine("Total Memory: " + MyValueFormatter.GetFormatedLong(GC.GetTotalMemory(false)) + " bytes"); } // Inform us if there were some garbage collection if (MyMwcFinalBuildConstants.EnableLoggingGarbageCollectionCalls) { int newGc = MyGarbageCollectionManager.GetGarbageCollectionsCountFromLastCall(); if (newGc > 0) { MyMwcLog.WriteLine("####### Garbage collections from the last call: " + newGc + " #######"); } } int updateManagersBlock = -1; MyRender.GetRenderProfiler().StartProfilingBlock("UpdateManagers", ref updateManagersBlock); MyRender.GetRenderProfiler().EndProfilingBlock(updateManagersBlock); // Now I think that it's better if HandleInput is called after Update, because then input methods // such as Shot() have up-to-date values such as position, forward vector, etc int guiManagerBlock = -1; MyRender.GetRenderProfiler().StartProfilingBlock("GuiManager", ref guiManagerBlock); MyGuiManager.Update(); MyRender.GetRenderProfiler().EndProfilingBlock(guiManagerBlock); //After guimanager update because of object world matrices updates of objects MyParticlesManager.Update(); int inputBlock = -1; MyRender.GetRenderProfiler().StartProfilingBlock("Input", ref inputBlock); MyGuiManager.HandleInput(); MyRender.GetRenderProfiler().EndProfilingBlock(inputBlock); int serverUpdateBlock = -1; MyRender.GetRenderProfiler().StartProfilingBlock("MyClientServer.Update", ref serverUpdateBlock); //MyClientServer.Update(); ti MyRender.GetRenderProfiler().EndProfilingBlock(serverUpdateBlock); if (MyMwcFinalBuildConstants.SimulateSlowUpdate) { System.Threading.Thread.Sleep(7); } int audioUpdateBlock = -1; MyRender.GetRenderProfiler().StartProfilingBlock("MyAudio.Update", ref audioUpdateBlock); MyAudio.Update(); MyDialogues.Update(); MyRender.GetRenderProfiler().EndProfilingBlock(audioUpdateBlock); int othersBlock = -1; MyRender.GetRenderProfiler().StartProfilingBlock("Others", ref othersBlock); if (MyMwcFinalBuildConstants.EnableLoggingInDrawAndUpdateAndGuiLoops == true) { if (MyMwcLog.IsIndentKeyIncreased()) { MyMwcLog.DecreaseIndent(); } MyMwcLog.WriteLine("MyMinerGame.Update() - END"); } ProcessInvoke(); if (OnGameUpdate != null) { OnGameUpdate(gameTime); } base.Update(gameTime); MyRender.GetRenderProfiler().EndProfilingBlock(othersBlock); MyRender.GetRenderProfiler().EndProfilingBlock(updateBlock); }