Example #1
0
 // Arguments ordered in this BS way for ease of IL use  (dup)
 private static void GridSystemEntry(object system, IMyEntity grid, ref MultiProfilerEntry mpe)
 {
     if (_activeProfilers == 0)
     {
         return;
     }
     if (grid != null)
     {
         EntityEntry(grid, ref mpe);
     }
 }
Example #2
0
        private static void EntityComponentEntry(MyEntityComponentBase component, ref MultiProfilerEntry mpe)
        {
            if (_activeProfilers == 0)
            {
                return;
            }

            if (component.Entity != null)
            {
                EntityEntry(component.Entity, ref mpe);
            }

            // ReSharper disable once InvertIf
            if (_activeProfilersByType[(int)ProfilerRequestType.Mod] > 0)
            {
                var modContext = ModLookupUtils.GetMod(component.GetType()) ?? MyModContext.BaseGame;
                mpe.Add(PerfMod.GetOrAdd(modContext, DelMakeMod));
            }
        }
Example #3
0
        private static void SessionComponentEntry(MySessionComponentBase component, ref MultiProfilerEntry mpe)
        {
            if (_activeProfilers == 0)
            {
                return;
            }

            if (_modMask != null && component.ModContext != _modMask)
            {
                return;
            }

            if (_activeProfilersByType[(int)ProfilerRequestType.Mod] > 0)
            {
                var modContext = ModLookupUtils.GetMod(component) ?? MyModContext.BaseGame;
                mpe.Add(PerfMod.GetOrAdd(modContext, DelMakeMod));
            }

            if (_activeProfilersByType[(int)ProfilerRequestType.Session] > 0)
            {
                mpe.Add(PerfSessionComponent.GetOrAdd(component.GetType(), DelMakeSessionComponent));
            }
        }
Example #4
0
 private static void SuffixProfilePb(ref MultiProfilerEntry __localProfilerHandle)
 {
     __localProfilerHandle.Stop();
 }
Example #5
0
 // ReSharper disable InconsistentNaming
 // ReSharper disable once SuggestBaseTypeForParameter
 private static void PrefixProfilePb(MyProgrammableBlock __instance, ref MultiProfilerEntry __localProfilerHandle)
 {
     __localProfilerHandle = default(MultiProfilerEntry);
     ProfilerData.EntityEntry(__instance, ref __localProfilerHandle);
     __localProfilerHandle.Start();
 }
Example #6
0
        public static void EntityEntry(IMyEntity entity, ref MultiProfilerEntry mpe)
        {
            if (!AcceptEntity(entity))
            {
                return;
            }

            do
            {
                switch (entity)
                {
                case MyCubeBlock block:
                {
                    if (block.BlockDefinition != null && (_activeProfilersByType[(int)ProfilerRequestType.BlockDef] > 0 ||
                                                          _activeProfilersByType[(int)ProfilerRequestType.BlockType] > 0))
                    {
                        var def = block.BlockDefinition.Id;
                        mpe.Add(PerfBlockType.GetOrAdd(def.TypeId, DelMakeBlockType));
                        mpe.Add(PerfBlockDef.GetOrAdd(block.BlockDefinition, DelMakeBlockDefinition));
                    }

                    if (block.CubeGrid != null && _activeProfilersByType[(int)ProfilerRequestType.Grid] > 0)
                    {
                        mpe.Add(PerfGrid.GetOrAdd(block.CubeGrid.EntityId, DelMakeGrid));
                    }

                    if (block is MyProgrammableBlock && _activeProfilersByType[(int)ProfilerRequestType.Scripts] > 0)
                    {
                        mpe.Add(PerfScript.GetOrAdd(block.EntityId, DelMakeScript));
                    }

                    if (_activeProfilersByType[(int)ProfilerRequestType.Players] > 0)
                    {
                        mpe.Add(PerfPlayer.GetOrAdd(block.BuiltBy, DelMakePlayer));
                    }

                    if (_activeProfilersByType[(int)ProfilerRequestType.Faction] <= 0)
                    {
                        return;
                    }
                    var faction = MySession.Static.Factions.TryGetPlayerFaction(block.BuiltBy);
                    PerfFaction.GetOrAdd(faction?.FactionId ?? 0, DelMakeFaction);
                    return;
                }

                case MyCubeGrid grid:
                {
                    if (_activeProfilersByType[(int)ProfilerRequestType.Grid] > 0)
                    {
                        mpe.Add(PerfGrid.GetOrAdd(grid.EntityId, DelMakeGrid));
                    }

                    if (_activeProfilersByType[(int)ProfilerRequestType.Players] <= 0 &&
                        _activeProfilersByType[(int)ProfilerRequestType.Faction] <= 0)
                    {
                        return;
                    }

                    var addedFaction = false;
                    foreach (var owner in grid.BigOwners)
                    {
                        if (!addedFaction)
                        {
                            var faction = MySession.Static.Factions.TryGetPlayerFaction(owner);
                            if (faction != null)
                            {
                                addedFaction = mpe.Add(PerfFaction.GetOrAdd(faction.FactionId, DelMakeFaction));
                            }
                        }

                        mpe.Add(PerfPlayer.GetOrAdd(owner, DelMakePlayer));
                    }

                    if (!addedFaction)
                    {
                        mpe.Add(PerfFaction.GetOrAdd(0, DelMakeFaction));
                    }
                    return;
                }
                }

                entity = entity.Parent;
            } while (entity != null);
        }