Пример #1
0
        public static void UpdateEntityEmitters(bool removeUnused, bool updatePlaying, bool updateNotPlaying)
        {
            int sessionTotalFrames = MyFpsManager.GetSessionTotalFrames();

            if ((sessionTotalFrames != 0) && (Math.Abs((int)(m_lastUpdate - sessionTotalFrames)) >= 5))
            {
                m_lastUpdate = sessionTotalFrames;
                List <MyEntity3DSoundEmitter> entityEmitters = m_entityEmitters;
                lock (entityEmitters)
                {
                    for (int i = 0; i < m_entityEmitters.Count; i++)
                    {
                        if (((m_entityEmitters[i] != null) && (m_entityEmitters[i].Entity != null)) && !m_entityEmitters[i].Entity.Closed)
                        {
                            if ((m_entityEmitters[i].IsPlaying & updatePlaying) || (!m_entityEmitters[i].IsPlaying & updateNotPlaying))
                            {
                                m_entityEmitters[i].Update();
                            }
                        }
                        else if (removeUnused)
                        {
                            m_entityEmitters.RemoveAt(i);
                            i--;
                        }
                    }
                }
            }
        }
Пример #2
0
        private static bool CheckForSynchronizedSounds(MyGuiSounds sound)
        {
            MySoundData soundData = MyAudio.Static.GetCue(m_sounds[sound].SoundId);

            if (soundData != null && soundData.PreventSynchronization >= 0)
            {
                int lastTime;
                int now = MyFpsManager.GetSessionTotalFrames();
                if (m_lastTimePlaying.TryGetValue(sound, out lastTime))
                {
                    if (Math.Abs(now - lastTime) <= soundData.PreventSynchronization)
                    {
                        return(false);
                    }
                    else
                    {
                        m_lastTimePlaying[sound] = now;
                    }
                }
                else
                {
                    m_lastTimePlaying.Add(sound, now);
                }
            }
            return(true);
        }
Пример #3
0
        public static void UpdateEntityEmitters(bool removeUnused, bool updatePlaying, bool updateNotPlaying)
        {
            int now = MyFpsManager.GetSessionTotalFrames();

            if (now == 0 || Math.Abs(m_lastUpdate - now) < 5)
            {
                return;
            }
            m_lastUpdate = now;
            for (int i = 0; i < m_entityEmitters.Count; i++)
            {
                if (m_entityEmitters[i].Entity != null && m_entityEmitters[i].Entity.Closed == false)
                {
                    if ((m_entityEmitters[i].IsPlaying && updatePlaying) || (!m_entityEmitters[i].IsPlaying && updateNotPlaying))
                    {
                        m_entityEmitters[i].Update();
                    }
                }
                else if (removeUnused)
                {
                    m_entityEmitters.RemoveAt(i);
                    i--;
                }
            }
        }
Пример #4
0
        private static MyGameplayEndAnalytics GetGameplayEndAnalyticsData()
        {
            MyFpsManager.PrepareMinMax();
            string multiplayerType = "Off-line";

            if (MyMultiplayer.Static != null)
            {
                if (MySession.Static != null && MySession.Static.LocalCharacter != null && MyMultiplayer.Static.HostName.Equals(MySession.Static.LocalCharacter.DisplayNameText))
                {
                    multiplayerType = "Host";
                }
                else if (MyMultiplayer.Static.HostName.Equals("Dedicated server"))
                {
                    multiplayerType = "Dedicated server";
                }
                else
                {
                    multiplayerType = "Client";
                }
            }
            MyGameplayEndAnalytics data = new MyGameplayEndAnalytics
            {
                AverageFramesPerSecond  = (uint)(MyFpsManager.GetSessionTotalFrames() / MySession.Static.ElapsedPlayTime.TotalSeconds),
                AverageUpdatesPerSecond = (uint)(MyGameStats.Static.UpdateCount / MySession.Static.ElapsedPlayTime.TotalSeconds),

                MinFramesPerSecond     = (uint)MyFpsManager.GetMinSessionFPS(),
                MaxFramesPerSecond     = (uint)MyFpsManager.GetMaxSessionFPS(),
                TotalAmountMined       = MySession.Static.AmountMined,
                TimeOnBigShipSeconds   = (uint)MySession.Static.TimeOnBigShip.TotalSeconds,
                TimeOnSmallShipSeconds = (uint)MySession.Static.TimeOnSmallShip.TotalSeconds,
                TimeOnFootSeconds      = (uint)MySession.Static.TimeOnFoot.TotalSeconds,
                TimeOnJetpackSeconds   = (uint)MySession.Static.TimeOnJetpack.TotalSeconds,
                TotalDamageDealt       = MySession.Static.TotalDamageDealt,
                TotalBlocksCreated     = MySession.Static.TotalBlocksCreated,
                TotalPlayTime          = (uint)MySession.Static.ElapsedPlayTime.TotalSeconds,
                Scenario           = (bool)MySession.Static.IsScenario,
                voxelSupport       = MySession.Static.Settings.EnableConvertToStation,
                destructibleBlocks = MySession.Static.Settings.DestructibleBlocks,
                destructibleVoxels = MySession.Static.Settings.EnableVoxelDestruction,
                jetpack            = MySession.Static.Settings.EnableJetpack,
                hostility          = MySession.Static.Settings.EnvironmentHostility.ToString(),
                drones             = MySession.Static.Settings.EnableDrones,
                Wolfs               = MySession.Static.Settings.EnableWolfs != null ? (bool)MySession.Static.Settings.EnableWolfs : false,
                spaceSpiders        = MySession.Static.Settings.EnableSpiders != null ? (bool)MySession.Static.Settings.EnableSpiders : false,
                encounters          = MySession.Static.Settings.EnableEncounters,
                oxygen              = MySession.Static.Settings.EnableOxygen,
                toolShake           = MySession.Static.Settings.EnableToolShake,
                inventorySpace      = MySession.Static.Settings.InventorySizeMultiplier,
                welderSpeed         = MySession.Static.Settings.WelderSpeedMultiplier,
                grinderSpeed        = MySession.Static.Settings.GrinderSpeedMultiplier,
                refinerySpeed       = MySession.Static.Settings.RefinerySpeedMultiplier,
                assemblerEfficiency = MySession.Static.Settings.AssemblerEfficiencyMultiplier,
                assemblerSpeed      = MySession.Static.Settings.AssemblerSpeedMultiplier,
                floatingObjects     = (uint)MySession.Static.Settings.MaxFloatingObjects,
                worldName           = MySession.Static.Name,
                multiplayerType     = multiplayerType
            };

            return(data);
        }
Пример #5
0
 private bool CheckForSynchronizedSounds()
 {
     if ((this.m_lastSoundData != null) && (this.m_lastSoundData.PreventSynchronization >= 0))
     {
         LastTimePlayingData data;
         bool flag = LastTimePlaying.TryGetValue(this.SoundId, out data);
         if (!flag)
         {
             data.LastTime = 0;
             data.Emitter  = this;
             LastTimePlaying.TryAdd(this.SoundId, data);
         }
         int sessionTotalFrames = MyFpsManager.GetSessionTotalFrames();
         if (((sessionTotalFrames - data.LastTime) <= this.m_lastSoundData.PreventSynchronization) & flag)
         {
             MyAudio.Static.GetListenerPosition();
             if (this.SourcePosition.LengthSquared() > data.Emitter.SourcePosition.LengthSquared())
             {
                 return(false);
             }
         }
         data.LastTime = sessionTotalFrames;
         data.Emitter  = this;
         LastTimePlaying[this.SoundId] = data;
     }
     return(true);
 }
Пример #6
0
        public void MeteorShowerIncoming()
        {
            int sessionTotalFrames = MyFpsManager.GetSessionTotalFrames();

            if (this.CanChangeCategory && (Math.Abs((int)(this.m_lastMeteorShower - sessionTotalFrames)) >= 0xa8c0))
            {
                this.m_meteorShower     = 10;
                this.m_lastMeteorShower = sessionTotalFrames;
                this.m_noMusicTimer     = this.m_random.Next(1, 4);
                if (this.m_currentMusicCategory < MusicCategory.danger)
                {
                    this.PlayDangerMusic();
                }
            }
        }
Пример #7
0
        public void BeforeStartComponents()
        {
            Static.TotalDamageDealt   = 0;
            Static.TotalBlocksCreated = 0;

            ElapsedPlayTime = new TimeSpan();
            m_timeOfSave    = MySandboxGame.Static.UpdateTime;

            MyFpsManager.Reset();
            MyAnalyticsHelper.ReportGameplayStart();
            foreach (var component in m_sessionComponents.Values)
            {
                component.BeforeStart();
            }
        }
Пример #8
0
        public void MeteorShowerIncoming()
        {
            int now = MyFpsManager.GetSessionTotalFrames();

            if (Math.Abs(m_lastMeteorShower - now) < METEOR_SHOWER_MUSIC_FREQUENCY)
            {
                return;
            }
            m_meteorShower     = 10;
            m_lastMeteorShower = now;
            m_noMusicTimer     = m_random.Next(FAST_NO_MUSIC_TIME_MIN, FAST_NO_MUSIC_TIME_MAX);
            if ((int)m_currentMusicCategory < (int)MusicCategory.danger)
            {
                PlayDangerMusic();
            }
        }
Пример #9
0
        private static MyGameplayEndAnalytics GetGameplayEndAnalyticsData()
        {
            MyGameplayEndAnalytics data = new MyGameplayEndAnalytics
            {
                AverageFramesPerSecond = (int)(MyFpsManager.GetSessionTotalFrames() / MySession.Static.ElapsedPlayTime.TotalSeconds),
                MinFramesPerSecond     = MyFpsManager.GetMinSessionFPS(),
                MaxFramesPerSecond     = MyFpsManager.GetMaxSessionFPS(),
                TotalAmountMined       = MySession.Static.AmountMined,
                TimeOnBigShipSeconds   = (uint)MySession.Static.TimeOnBigShip.TotalSeconds,
                TimeOnSmallShipSeconds = (uint)MySession.Static.TimeOnSmallShip.TotalSeconds,
                TimeOnFootSeconds      = (uint)MySession.Static.TimeOnFoot.TotalSeconds,
                TimeOnJetpackSeconds   = (uint)MySession.Static.TimeOnJetpack.TotalSeconds
            };

            return(data);
        }
Пример #10
0
        public void Update()
        {
            UpdateCount++;

            double totalSeconds = (DateTime.UtcNow - m_lastStatMeasurePerSecond).TotalSeconds;

            if (totalSeconds >= 1.0)
            {
                UpdatesPerSecond           = (UpdateCount - m_previousUpdateCount);
                m_previousUpdateCount      = UpdateCount;
                m_lastStatMeasurePerSecond = DateTime.UtcNow;
                if (MyFakes.ENABLE_NETGRAPH)
                {
                    MyHud.Netgraph.UpdatesPerSecond = UpdatesPerSecond;
                    MyHud.Netgraph.FramesPerSecond  = MyFpsManager.GetFps();
                }
            }
        }
Пример #11
0
        public void SetTexts()
        {
            MyMwcUtils.ClearStringBuilder(m_debugText);

            m_debugText.Append("FPS: ");
            m_debugText.AppendInt32(MyFpsManager.GetFps());
            m_debugText.AppendLine();

            m_debugText.Append("Frame time: ");
            m_debugText.AppendDecimal(MyFpsManager.FrameTime, 1);
            m_debugText.Append(" ms");
            m_debugText.AppendLine();

            m_debugText.Append("Frame avg time: ");
            m_debugText.AppendDecimal(MyFpsManager.FrameTimeAvg, 1);
            m_debugText.Append(" ms");
            m_debugText.AppendLine();

            m_debugText.Append("Frame min time: ");
            m_debugText.AppendDecimal(MyFpsManager.FrameTimeMin, 1);
            m_debugText.Append(" ms");
            m_debugText.AppendLine();

            m_debugText.Append("Frame max time: ");
            m_debugText.AppendDecimal(MyFpsManager.FrameTimeMax, 1);
            m_debugText.Append(" ms");
            m_debugText.AppendLine();

            m_debugText.Append("Environment map update time: ");
            m_debugText.AppendDecimal(MinerWars.AppCode.Game.Render.EnvironmentMap.MyEnvironmentMap.LastUpdateTime, 1);
            m_debugText.Append(" ms");
            m_debugText.AppendLine();

            if (MyMwcFinalBuildConstants.IS_DEVELOP)
            {
                m_debugText.AppendLine();
                MyPerformanceCounter.PerCameraDraw.AppendCustomCounters(m_debugText);
                m_debugText.AppendLine();
                MyPerformanceCounter.PerCameraDraw.AppendCustomTimers(m_debugText);
            }
        }
Пример #12
0
        protected virtual Dictionary <string, object> GetGameplayEndData()
        {
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            try
            {
                MyFpsManager.PrepareMinMax();
                dictionary["game_duration"]           = (uint)MySession.Static.ElapsedPlayTime.TotalSeconds;
                dictionary["entire_world_duration"]   = (uint)MySession.Static.ElapsedGameTime.TotalSeconds;
                dictionary["fps_average"]             = (uint)(((double)MyFpsManager.GetSessionTotalFrames()) / MySession.Static.ElapsedPlayTime.TotalSeconds);
                dictionary["fps_minimum"]             = (uint)MyFpsManager.GetMinSessionFPS();
                dictionary["fps_maximum"]             = (uint)MyFpsManager.GetMaxSessionFPS();
                dictionary["ups_average"]             = (uint)(((double)MyGameStats.Static.UpdateCount) / MySession.Static.ElapsedPlayTime.TotalSeconds);
                dictionary["simspeed_client_average"] = (float)(((double)MySession.Static.SessionSimSpeedPlayer) / MySession.Static.ElapsedPlayTime.TotalSeconds);
                dictionary["simspeed_server_average"] = (float)(((double)MySession.Static.SessionSimSpeedServer) / MySession.Static.ElapsedPlayTime.TotalSeconds);
            }
            catch (Exception exception)
            {
                dictionary["failed_to_get_data"] = exception.Message + "\n" + exception.StackTrace;
            }
            return(dictionary);
        }
Пример #13
0
 private bool CheckForSynchronizedSounds()
 {
     if (m_lastSoundData != null && m_lastSoundData.PreventSynchronization >= 0)
     {
         int lastTime;
         int now = MyFpsManager.GetSessionTotalFrames();
         if (m_lastTimePlaying.TryGetValue(SoundId, out lastTime))
         {
             if (Math.Abs(now - lastTime) <= m_lastSoundData.PreventSynchronization)
             {
                 return(false);
             }
             else
             {
                 m_lastTimePlaying[SoundId] = now;
             }
         }
         else
         {
             m_lastTimePlaying.Add(SoundId, now);
         }
     }
     return(true);
 }
Пример #14
0
        public override bool Draw()
        {
            if (!base.Draw())
            {
                return(false);
            }

            float rowDistance = MyGuiConstants.DEBUG_STATISTICS_ROW_DISTANCE;
            float textScale   = MyGuiConstants.DEBUG_STATISTICS_TEXT_SCALE;

            m_stringIndex = 0;
            m_texts.Clear();
            m_rightAlignedtexts.Clear();


            m_texts.Add(StringBuilderCache.GetFormatedFloat("FPS: ", MyFpsManager.GetFps()));
            m_texts.Add(new StringBuilder("Renderer: ").Append(MyRenderProxy.RendererInterfaceName()));

            if (MySector.MainCamera != null)
            {
                m_texts.Add(GetFormatedVector3(StringBuilderCache, "Camera pos: ", MySector.MainCamera.Position));
            }

            m_texts.Add(MyScreenManager.GetGuiScreensForDebug());
            m_texts.Add(StringBuilderCache.GetFormatedBool("Paused: ", MySandboxGame.IsPaused));
            m_texts.Add(StringBuilderCache.GetFormatedDateTimeOffset("System Time: ", TimeUtil.LocalTime));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total GAME-PLAY Time: ", TimeSpan.FromMilliseconds(MySandboxGame.TotalGamePlayTimeInMilliseconds)));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Session Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.ElapsedPlayTime));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Foot Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnFoot));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Jetpack Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnJetpack));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Small Ship Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnSmallShip));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Big Ship Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnBigShip));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Time: ", TimeSpan.FromMilliseconds(MySandboxGame.TotalTimeInMilliseconds)));

            if (MySession.Static != null && MySession.Static.LocalCharacter != null)
            {
                var physGroup = MyExternalReplicable.FindByObject(MySession.Static.LocalCharacter).FindStateGroup <MyCharacterPhysicsStateGroup>();
                m_texts.Add(StringBuilderCache.GetFormatedBool("Character has support: ", physGroup != null && physGroup.DebugSupport != null));
            }

            m_texts.Add(StringBuilderCache.GetFormatedLong("GC.GetTotalMemory: ", GC.GetTotalMemory(false), " bytes"));

            if (MyFakes.DETECT_LEAKS)
            {
                var o = SharpDX.Diagnostics.ObjectTracker.FindActiveObjects();
                m_texts.Add(StringBuilderCache.GetFormatedInt("SharpDX Active object count: ", o.Count));
            }

            //TODO: I am unable to show this without allocations
            m_texts.Add(StringBuilderCache.GetFormatedLong("Environment.WorkingSet: ", WinApi.WorkingSet, " bytes"));

            // TODO: OP! Get available texture memory
            //m_texts.Add(StringBuilderCache.GetFormatedFloat("Available videomemory: ", MySandboxGame.Static.GraphicsDevice.AvailableTextureMemory / (1024.0f * 1024.0f), " MB"));
            m_texts.Add(StringBuilderCache.GetFormatedFloat("Allocated videomemory: ", 0, " MB"));

#if PHYSICS_SENSORS_PROFILING
            if (MyPhysics.physicsSystem != null)
            {
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - new allocated interactions: ", MyPhysics.physicsSystem.GetSensorInteractionModule().GetNewAllocatedInteractionsCount()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - interactions in use: ", MyPhysics.physicsSystem.GetSensorInteractionModule().GetInteractionsInUseCount()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - interactions in use MAX: ", MyPhysics.physicsSystem.GetSensorInteractionModule().GetInteractionsInUseCountMax()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - all sensors: ", MyPhysics.physicsSystem.GetSensorModule().SensorsCount()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - active sensors: ", MyPhysics.physicsSystem.GetSensorModule().ActiveSensors.Count));
            }
#endif

            m_texts.Add(StringBuilderCache.GetFormatedInt("Sound Instances Total 2D: ", MyAudio.Static.GetSoundInstancesTotal2D()));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Sound Instances Total 3D: ", MyAudio.Static.GetSoundInstancesTotal3D()));

            var tmp = StringBuilderCache;
            MyAudio.Static.WriteDebugInfo(tmp);
            m_texts.Add(tmp);
            for (int i = 0; i < 8; i++)
            {
                m_texts.Add(StringBuilderCache.Clear());
            }

            MyInput.Static.GetPressedKeys(m_pressedKeys);
            AddPressedKeys("Current keys              : ", m_pressedKeys);

            m_texts.Add(StringBuilderCache.Clear());
            m_texts.Add(m_frameDebugText);

            m_rightAlignedtexts.Add(m_frameDebugTextRA);

            Vector2 origin             = GetScreenLeftTopPosition();
            Vector2 rightAlignedOrigin = GetScreenRightTopPosition();

            for (int i = 0; i < m_texts.Count; i++)
            {
                MyGuiManager.DrawString(MyFontEnum.White, m_texts[i], origin + new Vector2(0, i * rowDistance), textScale,
                                        Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            }
            for (int i = 0; i < m_rightAlignedtexts.Count; i++)
            {
                MyGuiManager.DrawString(MyFontEnum.White, m_rightAlignedtexts[i], rightAlignedOrigin + new Vector2(-0.3f, i * rowDistance), textScale,
                                        Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            }

            ClearFrameDebugText();
            AddPerformanceCountersToFrameDebugText();

#if DEBUG
            //list of last played sounds
            MyGuiManager.DrawString(MyFontEnum.White, new StringBuilder("Last played sounds:"), rightAlignedOrigin + new Vector2(-0.3f, 0.8f), textScale,
                                    Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            int colorIndex = (MyCueBank.lastSoundIndex > 0) ? (MyCueBank.lastSoundIndex - 1) : (MyCueBank.lastSounds.Count - 1);//index of last sound
            for (int i = 0; i < MyCueBank.lastSounds.Count; i++)
            {
                MyGuiManager.DrawString(MyFontEnum.White, MyCueBank.lastSounds[i], rightAlignedOrigin + new Vector2(-0.275f, 0.8f + (1 + i) * rowDistance), textScale,
                                        (i == colorIndex ? Color.LightBlue : Color.Yellow), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            }
#endif

            return(true);
        }
        public override bool Update(bool hasFocus)
        {
            m_ticks = MyPerformanceCounter.ElapsedTicks;
            m_frameCounter++;

            double secondsFromStart = MyPerformanceCounter.TicksToMs(m_ticks - m_startTime) / 1000;

            if (secondsFromStart > 1)
            {
                double updateLagOverMeasureTime = (secondsFromStart - m_frameCounter * VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS);
                m_updateLag = updateLagOverMeasureTime / secondsFromStart * 1000;

                m_startTime    = m_ticks;
                m_frameCounter = 0;

                if (Sync.Layer != null)
                {
                    m_sentLastSec     = (Sync.Layer.TransportLayer.ByteCountSent - m_lastSent) / secondsFromStart;
                    m_receivedLastSec = (Sync.Layer.TransportLayer.ByteCountReceived - m_lastReceived) / secondsFromStart;

                    m_lastReceived = Sync.Layer.TransportLayer.ByteCountReceived;
                    m_lastSent     = Sync.Layer.TransportLayer.ByteCountSent;
                }
            }

            Stats.Timing.Write("FPS", MyFpsManager.GetFps(), VRage.Stats.MyStatTypeEnum.CurrentValue, 0, 0);
            Stats.Timing.Increment("UPS", 1000);
            Stats.Timing.Write("Simulation speed", Sandbox.Engine.Physics.MyPhysics.SimulationRatio, VRage.Stats.MyStatTypeEnum.CurrentValue, 100, 2);
            Stats.Timing.Write("Server simulation speed", Sync.ServerSimulationRatio, VRage.Stats.MyStatTypeEnum.CurrentValue, 100, 2);
            Stats.Timing.WriteFormat("Frame time: {0} ms", MyFpsManager.FrameTime, VRage.Stats.MyStatTypeEnum.CurrentValue, 0, 1);
            Stats.Timing.WriteFormat("Frame avg time: {0} ms", MyFpsManager.FrameTimeAvg, VRage.Stats.MyStatTypeEnum.CurrentValue, 0, 1);
            Stats.Timing.WriteFormat("Frame min time: {0} ms", MyFpsManager.FrameTimeMin, VRage.Stats.MyStatTypeEnum.CurrentValue, 0, 1);
            Stats.Timing.WriteFormat("Frame max time: {0} ms", MyFpsManager.FrameTimeMax, VRage.Stats.MyStatTypeEnum.CurrentValue, 0, 1);
            Stats.Timing.Write("Update lag (per s)", (float)m_updateLag, VRage.Stats.MyStatTypeEnum.CurrentValue, 0, 4);
            Stats.Timing.Write("GC Memory", GC.GetTotalMemory(false), VRage.Stats.MyStatTypeEnum.CurrentValue, 0, 0);
            Stats.Timing.Write("Process memory", WinApi.WorkingSet, VRage.Stats.MyStatTypeEnum.CurrentValue, 0, 0);
            Stats.Timing.Write("Active parcticle effects", MyParticlesManager.ParticleEffectsForUpdate.Count, VRage.Stats.MyStatTypeEnum.CurrentValue, 0, 0);
            Stats.Timing.Write("  particles total", MyParticlesManager.ParticlesTotal, VRage.Stats.MyStatTypeEnum.CurrentValue, 0, 0);

            if (MyPhysics.Clusters != null)
            {
                double i   = 0.0;
                double sum = 0.0;
                double max = 0.0;
                foreach (Havok.HkWorld havokWorld in MyPhysics.Clusters.GetList())
                {
                    i += 1.0;
                    var value = havokWorld.StepDuration.TotalMilliseconds;
                    sum += value;
                    if (value > max)
                    {
                        max = value;
                    }
                }
                Stats.Timing.WriteFormat("Physics worlds count: {0}", (float)i, VRage.Stats.MyStatTypeEnum.CurrentValue, 0, 0);
                Stats.Timing.WriteFormat("Physics step time (sum): {0} ms", (float)sum, VRage.Stats.MyStatTypeEnum.CurrentValue, 0, 1);
                Stats.Timing.WriteFormat("Physics step time (avg): {0} ms", (float)(sum / i), VRage.Stats.MyStatTypeEnum.CurrentValue, 0, 1);
                Stats.Timing.WriteFormat("Physics step time (max): {0} ms", (float)max, VRage.Stats.MyStatTypeEnum.CurrentValue, 0, 1);
            }

            if (Sync.Layer != null)
            {
                Stats.Timing.Write("Received KB/s", (float)m_receivedLastSec / 1024, VRage.Stats.MyStatTypeEnum.CurrentValue, 0, 2);
                Stats.Timing.Write("Sent KB/s", (float)m_sentLastSec / 1024, VRage.Stats.MyStatTypeEnum.CurrentValue, 0, 2);
            }

            return(base.Update(hasFocus));
        }
        public override bool Draw(float backgroundFadeAlpha)
        {
            if (base.Draw(backgroundFadeAlpha) == false)
            {
                return(false);
            }

            float rowDistance = MyGuiConstants.DEBUG_STATISTICS_ROW_DISTANCE;
            float textScale   = MyGuiConstants.DEBUG_STATISTICS_TEXT_SCALE;

            m_stringIndex = 0;
            m_texts.Clear();
            m_rightAlignedtexts.Clear();


            m_texts.Add(StringBuilderCache.GetFormatedFloat("FPS: ", MyFpsManager.GetFps()));

            m_texts.Add(MyGuiManager.GetGuiScreensForDebug());

            m_texts.Add(StringBuilderCache.GetFormatedBool("Paused: ", MyMinerGame.IsPaused()));
            m_texts.Add(StringBuilderCache.GetFormatedDateTimeOffset("System Time: ", TimeUtil.LocalTime));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total MISSION Time: ", MyMissions.ActiveMission == null ? TimeSpan.Zero : MyMissions.ActiveMission.MissionTimer.GetElapsedTime()));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total GAME-PLAY Time: ", TimeSpan.FromMilliseconds(MyMinerGame.TotalGamePlayTimeInMilliseconds)));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Time: ", TimeSpan.FromMilliseconds(MyMinerGame.TotalTimeInMilliseconds)));

            m_texts.Add(StringBuilderCache.GetFormatedLong("GC.GetTotalMemory: ", GC.GetTotalMemory(false), " bytes"));

//#if MEMORY_PROFILING
            //TODO: I am unable to show this without allocations
            m_texts.Add(StringBuilderCache.GetFormatedLong("Environment.WorkingSet: ", MyWindowsAPIWrapper.WorkingSet, " bytes"));

            m_texts.Add(StringBuilderCache.GetFormatedFloat("Available videomemory: ", MyMinerGame.Static.GraphicsDevice.AvailableTextureMemory / (1024.0f * 1024.0f), " MB"));
            // TODO: Videomem
            //m_texts.Add(StringBuilderCache.GetFormatedFloat("Allocated videomemory: ", MyProgram.GetResourcesSizeInMB(), " MB"));
//#endif

#if PHYSICS_SENSORS_PROFILING
            if (MinerWars.AppCode.Physics.MyPhysics.physicsSystem != null)
            {
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - new allocated interactions: ", MinerWars.AppCode.Physics.MyPhysics.physicsSystem.GetSensorInteractionModule().GetNewAllocatedInteractionsCount()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - interactions in use: ", MinerWars.AppCode.Physics.MyPhysics.physicsSystem.GetSensorInteractionModule().GetInteractionsInUseCount()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - interactions in use MAX: ", MinerWars.AppCode.Physics.MyPhysics.physicsSystem.GetSensorInteractionModule().GetInteractionsInUseCountMax()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - all sensors: ", MinerWars.AppCode.Physics.MyPhysics.physicsSystem.GetSensorModule().SensorsCount()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - active sensors: ", MinerWars.AppCode.Physics.MyPhysics.physicsSystem.GetSensorModule().ActiveSensors.Count));
            }
#endif

            m_texts.Add(StringBuilderCache.GetFormatedInt("Sound Instances Total 2D: ", MyAudio.GetSoundInstancesTotal2D()));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Sound Instances Total 3D: ", MyAudio.GetSoundInstancesTotal3D()));
            m_texts.Add(MyAudio.GetCurrentTransitionForDebug());
            if (MyAudio.GetMusicCue() != null)
            {
                //m_texts.Add(StringBuilderCache.GetStrings("Currently Playing Music Cue: ", MyAudio.GetMusicCue().Value.GetCue().Name));
            }

            m_texts.Add(StringBuilderCache.Clear());
            m_texts.Add(StringBuilderCache.GetFormatedInt("Textures 2D Count: ", MyPerformanceCounter.PerAppLifetime.Textures2DCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Textures 2D Size In Pixels: ", MyPerformanceCounter.PerAppLifetime.Textures2DSizeInPixels));
            m_texts.Add(StringBuilderCache.GetFormatedDecimal("Textures 2D Size In Mb: ", MyPerformanceCounter.PerAppLifetime.Textures2DSizeInMb, 3));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Dxt Compressed Textures Count: ", MyPerformanceCounter.PerAppLifetime.DxtCompressedTexturesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Non Dxt Compressed Textures Count: ", MyPerformanceCounter.PerAppLifetime.NonDxtCompressedTexturesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Non Mip Mapped Textures Count: ", MyPerformanceCounter.PerAppLifetime.NonMipMappedTexturesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Texture Cubes Count: ", MyPerformanceCounter.PerAppLifetime.TextureCubesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Texture Cubes Size In Pixels: ", MyPerformanceCounter.PerAppLifetime.TextureCubesSizeInPixels));
            m_texts.Add(StringBuilderCache.GetFormatedDecimal("Texture Cubes Size In Mb: ", MyPerformanceCounter.PerAppLifetime.TextureCubesSizeInMb, 3));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Non MyModels Count: ", MyPerformanceCounter.PerAppLifetime.ModelsCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Count: ", MyPerformanceCounter.PerAppLifetime.MyModelsCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Meshes Count: ", MyPerformanceCounter.PerAppLifetime.MyModelsMeshesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Vertexes Count: ", MyPerformanceCounter.PerAppLifetime.MyModelsVertexesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Triangles Count: ", MyPerformanceCounter.PerAppLifetime.MyModelsTrianglesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Size of Model Vertex Buffers in Mb: ", MyPerformanceCounter.PerAppLifetime.ModelVertexBuffersSize / 1024 / 1024));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Size of Model Index Buffers in Mb: ", MyPerformanceCounter.PerAppLifetime.ModelIndexBuffersSize / 1024 / 1024));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Size of Voxel Vertex Buffers in Mb: ", MyPerformanceCounter.PerAppLifetime.VoxelVertexBuffersSize / 1024 / 1024));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Size of Voxel Index Buffers in Mb: ", MyPerformanceCounter.PerAppLifetime.VoxelIndexBuffersSize / 1024 / 1024));
            m_texts.Add(StringBuilderCache.GetFormatedBool("Paused: ", MyMinerGame.IsPaused()));
            MyGuiManager.GetInput().GetPressedKeys(m_pressedKeys);
            AddPressedKeys("Current keys              : ", m_pressedKeys);

            m_texts.Add(StringBuilderCache.Clear());
            m_texts.Add(m_frameDebugText);


            //This ensures constant max length of right block to avoid flickering when correct max line is changing too often
            m_frameDebugTextRA.AppendLine();
            m_frameDebugTextRA.Append("                                                                  ");
            ////

            m_rightAlignedtexts.Add(m_frameDebugTextRA);

            Vector2 origin             = GetScreenLeftTopPosition();
            Vector2 rightAlignedOrigin = GetScreenRightTopPosition();

            for (int i = 0; i < m_texts.Count; i++)
            {
                MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsWhite(), m_texts[i], origin + new Vector2(0, i * rowDistance), textScale,
                                        Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            }
            for (int i = 0; i < m_rightAlignedtexts.Count; i++)
            {
                MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsWhite(), m_rightAlignedtexts[i], rightAlignedOrigin + new Vector2(0.0f, i * rowDistance), textScale,
                                        Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
            }

            ClearFrameDebugText();

            return(true);
        }
        public override bool Draw()
        {
            if (!base.Draw())
            {
                return(false);
            }

            float rowDistance = MyGuiConstants.DEBUG_STATISTICS_ROW_DISTANCE;
            float textScale   = MyGuiConstants.DEBUG_STATISTICS_TEXT_SCALE;

            m_stringIndex = 0;
            m_texts.Clear();
            m_rightAlignedtexts.Clear();


            m_texts.Add(StringBuilderCache.GetFormatedFloat("FPS: ", MyFpsManager.GetFps()));
            m_texts.Add(new StringBuilder("Renderer: ").Append(MyRenderProxy.RendererInterfaceName()));

            m_texts.Add(MyScreenManager.GetGuiScreensForDebug());
            m_texts.Add(StringBuilderCache.GetFormatedBool("Paused: ", MySandboxGame.IsPaused));
            m_texts.Add(StringBuilderCache.GetFormatedDateTimeOffset("System Time: ", TimeUtil.LocalTime));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total GAME-PLAY Time: ", TimeSpan.FromMilliseconds(MySandboxGame.TotalGamePlayTimeInMilliseconds)));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Session Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.ElapsedPlayTime));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Foot Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnFoot));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Jetpack Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnJetpack));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Small Ship Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnSmallShip));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Big Ship Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnBigShip));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Time: ", TimeSpan.FromMilliseconds(MySandboxGame.TotalTimeInMilliseconds)));

            m_texts.Add(StringBuilderCache.GetFormatedLong("GC.GetTotalMemory: ", GC.GetTotalMemory(false), " bytes"));

            if (MyFakes.DETECT_LEAKS)
            {
                var o = SharpDX.Diagnostics.ObjectTracker.FindActiveObjects();
                m_texts.Add(StringBuilderCache.GetFormatedInt("SharpDX Active object count: ", o.Count));
            }

            //TODO: I am unable to show this without allocations
            m_texts.Add(StringBuilderCache.GetFormatedLong("Environment.WorkingSet: ", WinApi.WorkingSet, " bytes"));

            // TODO: OP! Get available texture memory
            //m_texts.Add(StringBuilderCache.GetFormatedFloat("Available videomemory: ", MySandboxGame.Static.GraphicsDevice.AvailableTextureMemory / (1024.0f * 1024.0f), " MB"));
            m_texts.Add(StringBuilderCache.GetFormatedFloat("Allocated videomemory: ", 0, " MB"));

#if PHYSICS_SENSORS_PROFILING
            if (MyPhysics.physicsSystem != null)
            {
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - new allocated interactions: ", MyPhysics.physicsSystem.GetSensorInteractionModule().GetNewAllocatedInteractionsCount()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - interactions in use: ", MyPhysics.physicsSystem.GetSensorInteractionModule().GetInteractionsInUseCount()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - interactions in use MAX: ", MyPhysics.physicsSystem.GetSensorInteractionModule().GetInteractionsInUseCountMax()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - all sensors: ", MyPhysics.physicsSystem.GetSensorModule().SensorsCount()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - active sensors: ", MyPhysics.physicsSystem.GetSensorModule().ActiveSensors.Count));
            }
#endif

            m_texts.Add(StringBuilderCache.GetFormatedInt("Sound Instances Total 2D: ", MyAudio.Static.GetSoundInstancesTotal2D()));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Sound Instances Total 3D: ", MyAudio.Static.GetSoundInstancesTotal3D()));

            var tmp = StringBuilderCache;
            MyAudio.Static.WriteDebugInfo(tmp);
            m_texts.Add(tmp);
            for (int i = 0; i < 8; i++)
            {
                m_texts.Add(StringBuilderCache.Clear());
            }

            m_texts.Add(StringBuilderCache.GetFormatedInt("Updating 3D sounds count: ", MyAudio.Static.GetUpdating3DSoundsCount()));
            m_texts.Add(StringBuilderCache.Clear());
            m_texts.Add(StringBuilderCache.GetFormatedInt("Textures 2D Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.Textures2DCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Textures 2D Size In Pixels: ", VRageRender.MyPerformanceCounter.PerAppLifetime.Textures2DSizeInPixels));
            m_texts.Add(StringBuilderCache.AppendFormatedDecimal("Textures 2D Size In Mb: ", (float)VRageRender.MyPerformanceCounter.PerAppLifetime.Textures2DSizeInMb, 3));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Dxt Compressed Textures Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.DxtCompressedTexturesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Non Dxt Compressed Textures Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.NonDxtCompressedTexturesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Non Mip Mapped Textures Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.NonMipMappedTexturesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Texture Cubes Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.TextureCubesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Texture Cubes Size In Pixels: ", VRageRender.MyPerformanceCounter.PerAppLifetime.TextureCubesSizeInPixels));
            m_texts.Add(StringBuilderCache.AppendFormatedDecimal("Texture Cubes Size In Mb: ", (float)VRageRender.MyPerformanceCounter.PerAppLifetime.TextureCubesSizeInMb, 3));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Non MyModels Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.ModelsCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.MyModelsCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Meshes Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.MyModelsMeshesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Vertexes Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.MyModelsVertexesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Triangles Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.MyModelsTrianglesCount));
            m_texts.Add(StringBuilderCache.GetFormatedFloat("Size of Model Vertex Buffers in Mb: ", (float)VRageRender.MyPerformanceCounter.PerAppLifetime.ModelVertexBuffersSize / (1024 * 1024)));
            m_texts.Add(StringBuilderCache.GetFormatedFloat("Size of Model Index Buffers in Mb: ", (float)VRageRender.MyPerformanceCounter.PerAppLifetime.ModelIndexBuffersSize / (1024 * 1024)));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Size of Voxel Vertex Buffers in Mb: ", VRageRender.MyPerformanceCounter.PerAppLifetime.VoxelVertexBuffersSize / 1024 / 1024));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Size of Voxel Index Buffers in Mb: ", VRageRender.MyPerformanceCounter.PerAppLifetime.VoxelIndexBuffersSize / 1024 / 1024));
            m_texts.Add(StringBuilderCache.GetFormatedFloat("Size of loaded Model files in Mb: ", (float)VRageRender.MyPerformanceCounter.PerAppLifetime.MyModelsFilesSize / (1024 * 1024)));
            m_texts.Add(StringBuilderCache.GetFormatedBool("Paused: ", MySandboxGame.IsPaused));
            if (MySector.MainCamera != null)
            {
                m_texts.Add(GetFormatedVector3(StringBuilderCache, "Camera pos: ", MySector.MainCamera.Position));
            }

            MyInput.Static.GetPressedKeys(m_pressedKeys);
            AddPressedKeys("Current keys              : ", m_pressedKeys);

            m_texts.Add(StringBuilderCache.Clear());
            m_texts.Add(m_frameDebugText);

            m_rightAlignedtexts.Add(m_frameDebugTextRA);

            Vector2 origin             = GetScreenLeftTopPosition();
            Vector2 rightAlignedOrigin = GetScreenRightTopPosition();

            for (int i = 0; i < m_texts.Count; i++)
            {
                MyGuiManager.DrawString(MyFontEnum.White, m_texts[i], origin + new Vector2(0, i * rowDistance), textScale,
                                        Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            }
            for (int i = 0; i < m_rightAlignedtexts.Count; i++)
            {
                MyGuiManager.DrawString(MyFontEnum.White, m_rightAlignedtexts[i], rightAlignedOrigin + new Vector2(-0.3f, i * rowDistance), textScale,
                                        Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            }

            ClearFrameDebugText();
            AddPerformanceCountersToFrameDebugText();

            return(true);
        }
Пример #18
0
        protected override void Draw(GameTime gameTime)
        {
            if (m_debugFont == null)
            {
                return;
            }

//            MyRender.GetRenderProfiler().StartProfilingBlock("MyMinerGame::Draw");

            // if (MyMinerGame.IsDeviceResetted)
            //   return;

            /*
             * if (ResetSleep > 0)
             * {
             * ResetSleep--;
             * GraphicsDevice.Clear(Color.Black);
             * if (ResetSleep == 0)
             * {
             * MyMwcLog.WriteLine("Reset sleep - START");
             * MyTextureManager.ReloadTextures(false);
             * MyGuiManager.UpdateAfterDeviceReset();
             * MyMwcLog.WriteLine("Reset sleep - END");
             * }
             * return;
             * }     */

            if (MyMwcFinalBuildConstants.EnableLoggingInDrawAndUpdateAndGuiLoops)
            {
                MyMwcLog.WriteLine("MyMinerGame.Draw() - START");
                MyMwcLog.IncreaseIndent();
                MyMwcLog.WriteLine("Draw - gameTime.ElapsedGameTime: " + gameTime.ElapsedGameTime);
                MyMwcLog.WriteLine("Draw - gameTime.TotalGameTime: " + gameTime.TotalGameTime);
            }

            UpdateTimes(gameTime);
            MyFpsManager.Update();

            GraphicsDevice.Clear(ClearFlags.Target, new ColorBGRA(0.0f), 1, 0);

            if (GraphicsDevice.IsDisposed)
            {
                //MyMwcLog.WriteLine("MyMinerGame.Draw() - MyFakes.ALLOW_RENDER_HACK == false... skipping Draw");
                //MyRender.GetRenderProfiler().EndProfilingBlock();
                return;
            }

            /*
             * //  This hack is for PerfHUD. It will allow us to see correct PerfHUD GUI (not corrupted by some error), so we will see colors on graph menu.
             * if (MyMwcFinalBuildConstants.ENABLE_PERFHUD == true)
             * {
             * GraphicsDevice.DepthStencilState = DepthStencilState.Default;
             * }  */

            if (MyMwcFinalBuildConstants.SimulateSlowDraw == true)
            {
                System.Threading.Thread.Sleep(60);
            }

            //  MyRender.ResetStates();

            MyGuiManager.Draw();

            //  This hack is for PerfHUD. It will allow us to see correct PerfHUD GUI (not corrupted by some error), so we will see colors on graph menu.

            /*if (MyMwcFinalBuildConstants.ENABLE_PERFHUD == true)
             * {
             *  GraphicsDevice.DepthStencilState = DepthStencilState.None;
             * }      */


            DepthStencilState.None.Apply();
            RasterizerState.CullNone.Apply();
            BlendState.Opaque.Apply();

            //m_debugFont.DrawText(null, MyFpsManager.GetFps().ToString() + " (" + MyFpsManager.FrameTimeAvg.ToString() + "ms) ", 0, 0, new ColorBGRA(1.0f, 1.0f, 1.0f, 1.0f));


            if (MyMwcFinalBuildConstants.EnableLoggingInDrawAndUpdateAndGuiLoops == true)
            {
                MyMwcLog.DecreaseIndent();
                MyMwcLog.WriteLine("MyMinerGame.Draw() - END");
            }

            base.Draw(gameTime);

            if (OnGameDraw != null)
            {
                OnGameDraw(gameTime);
            }
        }