Example #1
0
        private void TargetBench(string[] args)
        {
            IMyTerminalBlock tblock;

            if (QuickActionHudSpace.TryGetTargetedBlock(100d, out tblock))
            {
                int  iterations;
                bool getProperties = false;

                int.TryParse(args[0], out iterations);

                if (args.Length > 1)
                {
                    bool.TryParse(args[1], out getProperties);
                }

                Stopwatch timer = new Stopwatch();
                timer.Start();

                var grid   = new TerminalGrid();
                var pBlock = new PropertyBlock();

                grid.SetGrid(tblock.CubeGrid);

                for (int n = 0; n < iterations; n++)
                {
                    IMyTerminalBlock temp;
                    QuickActionHudSpace.TryGetTargetedBlock(100d, out temp);
                    pBlock.SetBlock(grid, tblock);

                    if (getProperties)
                    {
                        pBlock.GetEnabledElementCount();
                    }
                }

                timer.Stop();
                ExceptionHandler.SendChatMessage
                (
                    $"Target Bench:\n" +
                    $"\tGetProperties: {getProperties}\n" +
                    $"\tTime: {(timer.ElapsedTicks / (double)TimeSpan.TicksPerMillisecond):G6} ms\n" +
                    $"\tIsHighResolution: {Stopwatch.IsHighResolution}\n" +
                    $"\tIterations: {iterations}"
                );
            }
            else
            {
                ExceptionHandler.SendChatMessage($"Cant start target bench. No target found.");
            }
        }
Example #2
0
        public virtual void SetBlock(TerminalGrid grid, IMyTerminalBlock tBlock)
        {
            Utils.Debug.AssertNotNull(tBlock);
            Utils.Debug.AssertNotNull(grid);

            Reset();
            TBlock       = tBlock;
            TerminalGrid = grid;

            TypeID = tBlock.BlockDefinition.TypeIdString;
            TBlock.OnMarkForClose += BlockClosing;

            AddBlockSubtypes();
        }
Example #3
0
        private QuickActionHudSpace() : base(HudMain.Root)
        {
            DrawBoundingBox = false;
            targetGrid      = new TerminalGrid();
            tempGrid        = new TerminalGrid();
            targetBuffer    = new List <IMySlimBlock>();
            Target          = new PropertyBlock();

            quickActionMenu = new QuickActionMenu(this);
            boundingBox     = new BoundingBoard();
            hudNotification = MyAPIGateway.Utilities.CreateNotification("", 1000, MyFontEnum.Red);

            frameTimer = new Stopwatch();
            frameTimer.Start();

            RichHudCore.LateMessageEntered += MessageHandler;
        }
Example #4
0
 public void GetGroupsForBlock(List <IMyBlockGroup> groups) =>
 TerminalGrid.GetGroupsForBlock(TBlock, groups);
Example #5
0
 public void GetGroupNamesForBlock(List <string> groups) =>
 TerminalGrid.GetGroupNamesForBlock(TBlock, groups);
Example #6
0
 public override void SetBlock(TerminalGrid grid, IMyTerminalBlock tBlock)
 {
     base.SetBlock(grid, tBlock);
     ModelOffset = tBlock.WorldAABB.Center - TBlock.GetPosition();
 }