Пример #1
0
        public static void UpdateBeforeSimulation()
        {
            if (MySandboxGame.IsGameReady == false)
            {
                return;
            }

            ProfilerShort.Begin("MyEntities.UpdateBeforeSimulation");
            System.Diagnostics.Debug.Assert(MyEntities.UpdateInProgress == false);
            MyEntities.UpdateInProgress = true;

            {
                ProfilerShort.Begin("Before first frame");
                MyEntities.UpdateOnceBeforeFrame();

                ProfilerShort.BeginNextBlock("Each update");
                m_entitiesForUpdate.List.ApplyChanges();
                m_entitiesForUpdate.Update();
                MySimpleProfiler.Begin("Blocks");
                m_entitiesForUpdate.Iterate((x) =>
                {
                    ProfilerShort.Begin(x.GetType().Name);
                    if (x.MarkedForClose == false)
                    {
                        if (ProfilePerBlock)
                        {
                            MyCubeBlock block = x as MyCubeBlock;
                            if (block != null)
                            {
                                MySimpleProfiler.Begin(block.DefinitionDisplayNameText + (ProfilePerGrid ? $" - {block.CubeGrid.DisplayName}" : string.Empty));
                                if (ProfilePerGrid)
                                {
                                    MySimpleProfiler.Begin("&&GRID&&" + block.CubeGrid.DisplayName);
                                }
                            }
                        }
                        if (ProfilePerGrid)
                        {
                            MyCubeGrid grid = x as MyCubeGrid;
                            if (grid != null)
                            {
                                MySimpleProfiler.Begin("&&GRID&&" + grid.DisplayName);
                            }
                        }

                        x.UpdateBeforeSimulation();

                        if (ProfilePerBlock)
                        {
                            MyCubeBlock block = x as MyCubeBlock;
                            if (block != null)
                            {
                                MySimpleProfiler.End(block.DefinitionDisplayNameText + (ProfilePerGrid ? $" - {block.CubeGrid.DisplayName}" : string.Empty));
                                if (ProfilePerGrid)
                                {
                                    MySimpleProfiler.End("&&GRID&&" + block.CubeGrid.DisplayName);
                                }
                            }
                        }
                        if (ProfilePerGrid)
                        {
                            MyCubeGrid grid = x as MyCubeGrid;
                            if (grid != null)
                            {
                                MySimpleProfiler.End("&&GRID&&" + grid.DisplayName);
                            }
                        }
                    }
                    ProfilerShort.End();
                });

                ProfilerShort.BeginNextBlock("10th update");
                m_entitiesForUpdate10.List.ApplyChanges();
                m_entitiesForUpdate10.Update();
                m_entitiesForUpdate10.Iterate((x) =>
                {
                    ProfilerShort.Begin(x.GetType().Name);
                    if (x.MarkedForClose == false)
                    {
                        if (ProfilePerBlock)
                        {
                            MyCubeBlock block = x as MyCubeBlock;
                            if (block != null)
                            {
                                MySimpleProfiler.Begin(block.DefinitionDisplayNameText + (ProfilePerGrid ? $" - {block.CubeGrid.DisplayName}" : string.Empty));
                                if (ProfilePerGrid)
                                {
                                    MySimpleProfiler.Begin("&&GRID&&" + block.CubeGrid.DisplayName);
                                }
                            }
                        }
                        if (ProfilePerGrid)
                        {
                            MyCubeGrid grid = x as MyCubeGrid;
                            if (grid != null)
                            {
                                MySimpleProfiler.Begin("&&GRID&&" + grid.DisplayName);
                            }
                        }

                        x.UpdateBeforeSimulation10();

                        if (ProfilePerBlock)
                        {
                            MyCubeBlock block = x as MyCubeBlock;
                            if (block != null)
                            {
                                MySimpleProfiler.End(block.DefinitionDisplayNameText + (ProfilePerGrid ? $" - {block.CubeGrid.DisplayName}" : string.Empty));
                                if (ProfilePerGrid)
                                {
                                    MySimpleProfiler.End("&&GRID&&" + block.CubeGrid.DisplayName);
                                }
                            }
                        }
                        if (ProfilePerGrid)
                        {
                            MyCubeGrid grid = x as MyCubeGrid;
                            if (grid != null)
                            {
                                MySimpleProfiler.End("&&GRID&&" + grid.DisplayName);
                            }
                        }
                    }
                    ProfilerShort.End();
                });


                ProfilerShort.BeginNextBlock("100th update");
                m_entitiesForUpdate100.List.ApplyChanges();
                m_entitiesForUpdate100.Update();
                m_entitiesForUpdate100.Iterate((x) =>
                {
                    ProfilerShort.Begin(x.GetType().Name);
                    if (x.MarkedForClose == false)
                    {
                        if (ProfilePerBlock)
                        {
                            MyCubeBlock block = x as MyCubeBlock;
                            if (block != null)
                            {
                                MySimpleProfiler.Begin(block.DefinitionDisplayNameText + (ProfilePerGrid ? $" - {block.CubeGrid.DisplayName}" : string.Empty));
                                if (ProfilePerGrid)
                                {
                                    MySimpleProfiler.Begin("&&GRID&&" + block.CubeGrid.DisplayName);
                                }
                            }
                        }
                        if (ProfilePerGrid)
                        {
                            MyCubeGrid grid = x as MyCubeGrid;
                            if (grid != null)
                            {
                                MySimpleProfiler.Begin("&&GRID&&" + grid.DisplayName);
                            }
                        }

                        x.UpdateBeforeSimulation100();

                        if (ProfilePerBlock)
                        {
                            MyCubeBlock block = x as MyCubeBlock;
                            if (block != null)
                            {
                                MySimpleProfiler.End(block.DefinitionDisplayNameText + (ProfilePerGrid ? $" - {block.CubeGrid.DisplayName}" : string.Empty));
                                if (ProfilePerGrid)
                                {
                                    MySimpleProfiler.End("&&GRID&&" + block.CubeGrid.DisplayName);
                                }
                            }
                        }
                        if (ProfilePerGrid)
                        {
                            MyCubeGrid grid = x as MyCubeGrid;
                            if (grid != null)
                            {
                                MySimpleProfiler.Begin("&&GRID&&" + grid.DisplayName);
                            }
                        }
                    }
                    ProfilerShort.End();
                });

                ProfilerShort.End();
            }
            MySimpleProfiler.End("Blocks");

            MyEntities.UpdateInProgress = false;

            ProfilerShort.End();
        }
Пример #2
0
 public override void IterateRange(Action <IMyReplicable> p)
 {
     m_updateList.Update();
     m_updateList.Iterate(p);
 }