Exemplo n.º 1
0
        protected override void ProcessGrid(IMyCubeGrid TargetGrid, int ticks)
        {
            if (!MyAPIGateway.Multiplayer.IsServer)
            {
                return;
            }
            if (TargetGrid.EntityId == ToolGrid.EntityId)
            {
                return;
            }
            List <IMySlimBlock> Blocks  = new List <IMySlimBlock>();
            List <LineD>        RayGrid = new List <LineD> {
                new LineD(BeamCtlModule.BeamStart, BeamCtlModule.BeamEnd)
            };

            if (!TermModule.DistanceMode)
            {
                Vector3D UpOffset    = Vector3D.Normalize(Tool.WorldMatrix.Up) * 0.5;
                Vector3D RightOffset = Vector3D.Normalize(Tool.WorldMatrix.Right) * 0.5;
                RayGrid = VectorExtensions.BuildLineGrid(BeamCtlModule.BeamStart, BeamCtlModule.BeamEnd, UpOffset, RightOffset, 2, 2);
            }

            TargetGrid.GetBlocksOnRay(RayGrid, Blocks, x => x.IsGrindable());
            Grind(Blocks, ticks);
        }
Exemplo n.º 2
0
        protected override void ProcessGrid(IMyCubeGrid TargetGrid, int ticks)
        {
            List <IMySlimBlock> Blocks = new List <IMySlimBlock>();
            List <LineD>        RayGrid;

            if (!TermModule.DistanceMode)
            {
                Vector3D UpOffset    = Vector3D.Normalize(Tool.WorldMatrix.Up) * 0.5;
                Vector3D RightOffset = Vector3D.Normalize(Tool.WorldMatrix.Right) * 0.5;
                RayGrid = VectorExtensions.BuildLineGrid(BeamCtlModule.BeamStart, BeamCtlModule.BeamEnd, UpOffset, RightOffset, SessionCore.Settings.WorkingZoneWidth, SessionCore.Settings.WorkingZoneWidth);
                if (TargetGrid.Physics?.Enabled == true)
                {
                    TargetGrid.GetBlocksOnRay(RayGrid, Blocks, x => x.IsWeldable());
                    if (SessionCore.Settings.Debug && SessionCore.Settings.DebugPerformance)
                    {
                        SessionCore.DebugAsync(Tool.CustomName, $"Welding {Blocks.CollapseDuplicates().Count} blocks", WriteOnlyIfDebug: true);
                    }
                    if (MyAPIGateway.Multiplayer.IsServer)
                    {
                        Weld(Blocks, ticks);
                    }
                }
                else
                {
                    TargetGrid.GetBlocksOnRay(RayGrid, Blocks, x => x.IsProjectable());
                    if (Blocks.Count == 0)
                    {
                        return;
                    }
                    SessionCore.DebugAsync(Tool.CustomName, $"Placing {Blocks.Count} blocks", WriteOnlyIfDebug: true);
                    try
                    {
                        Place(Blocks);
                    }
                    catch (Exception Scrap)
                    {
                        SessionCore.DebugAsync(Tool.CustomName, $"Place() crashed: {Scrap.Message}\n{Scrap.StackTrace}");
                    }
                }
            }
            else
            {
                RayGrid = new List <LineD> {
                    new LineD(BeamCtlModule.BeamStart, BeamCtlModule.BeamEnd)
                };
                if (TargetGrid.Physics?.Enabled == true)
                {
                    TargetGrid.GetBlocksOnRay(RayGrid, Blocks, x => x.IsWeldable());
                    if (MyAPIGateway.Multiplayer.IsServer)
                    {
                        Weld(Blocks, ticks);
                    }
                }
                else
                {
                    TargetGrid.GetBlocksOnRay(RayGrid, Blocks, x => x.IsProjectable());
                    Place(Blocks);
                }
            }
        }
Exemplo n.º 3
0
        protected override void ProcessGrid(IMyCubeGrid TargetGrid, int ticks)
        {
            List <IMySlimBlock> Blocks = new List <IMySlimBlock>();
            List <LineD>        RayGrid;

            if (!DistanceMode)
            {
                Vector3D UpOffset    = Vector3D.Normalize(Tool.WorldMatrix.Up) * 0.5;
                Vector3D RightOffset = Vector3D.Normalize(Tool.WorldMatrix.Right) * 0.5;
                RayGrid = VectorExtensions.BuildLineGrid(BeamStart, BeamEnd, UpOffset, RightOffset, 2, 2);
                TargetGrid.GetBlocksOnRay(RayGrid, Blocks, x => x.IsProjectable() || x.IsWeldable());
                Weld(Blocks, ticks);
            }
            else
            {
                RayGrid = new List <LineD> {
                    new LineD(BeamStart, BeamEnd)
                };
                TargetGrid.GetBlocksOnRay(RayGrid, Blocks, x => x.IsProjectable() || x.IsWeldable());
                WeldDistanceMode(Blocks, ticks);
            }
        }