コード例 #1
0
        private void HandleRotateCommand(int?maybeangle, string centerarg)
        {
            //EnumOrigin origin = (centerarg != null && centerarg.StartsWith("c")) ? EnumOrigin.BottomCenter : EnumOrigin.StartPos;

            if (workspace.StartMarker == null || workspace.EndMarker == null)
            {
                Bad("Start marker or end marker not set");
                return;
            }

            int angle = 90;

            if (maybeangle != null)
            {
                if (((int)maybeangle / 90) * 90 != (int)maybeangle)
                {
                    Bad("Only intervals of 90 degrees are allowed angles");
                    return;
                }
            }

            EnumOrigin origin = EnumOrigin.BottomCenter;
            BlockPos   mid    = (workspace.StartMarker + workspace.EndMarker) / 2;

            BlockSchematic schematic = CopyArea(workspace.StartMarker, workspace.EndMarker);

            schematic.TransformWhilePacked(sapi.World, origin, angle, null);
            FillArea(null, workspace.StartMarker, workspace.EndMarker);

            PasteBlockData(schematic, mid, origin);

            ResendBlockHighlights();
        }
コード例 #2
0
        private void HandleRotateCommand(int?maybeangle, string centerarg)
        {
            //EnumOrigin origin = (centerarg != null && centerarg.StartsWith("c")) ? EnumOrigin.BottomCenter : EnumOrigin.StartPos;

            if (workspace.StartMarker == null || workspace.EndMarker == null)
            {
                Bad("Start marker or end marker not set");
                return;
            }

            int angle = 90;

            if (maybeangle != null)
            {
                if (((int)maybeangle / 90) * 90 != (int)maybeangle)
                {
                    Bad("Only intervals of 90 degrees are allowed angles");
                    return;
                }
            }

            EnumOrigin origin = EnumOrigin.BottomCenter;
            BlockPos   mid    = (workspace.StartMarker + workspace.EndMarker) / 2;

            mid.Y = workspace.StartMarker.Y;

            BlockSchematic schematic = CopyArea(workspace.StartMarker, workspace.EndMarker);

            workspace.revertableBlockAccess.BeginMultiEdit();

            schematic.TransformWhilePacked(sapi.World, origin, angle, null);
            FillArea(null, workspace.StartMarker, workspace.EndMarker);

            PasteBlockData(schematic, mid, origin);

            workspace.StartMarker = schematic.GetStartPos(mid, origin);
            workspace.EndMarker   = workspace.StartMarker.AddCopy(schematic.SizeX, schematic.SizeY, schematic.SizeZ);

            workspace.revertableBlockAccess.EndMultiEdit();

            workspace.HighlightSelectedArea();
        }
コード例 #3
0
        private void PasteBlockData(BlockSchematic blockData, BlockPos startPos, EnumOrigin origin)
        {
            BlockPos originPos = blockData.GetStartPos(startPos, origin);

            EnumAxis?axis = null;

            if (workspace.ImportFlipped)
            {
                axis = EnumAxis.Y;
            }

            BlockSchematic rotated = blockData.ClonePacked();

            rotated.TransformWhilePacked(sapi.World, origin, workspace.ImportAngle, axis);

            rotated.Init(workspace.revertableBlockAccess);
            rotated.Place(workspace.revertableBlockAccess, sapi.World, originPos, EnumReplaceMode.ReplaceAll, ReplaceMetaBlocks);
            workspace.revertableBlockAccess.Commit();

            blockData.PlaceEntitiesAndBlockEntities(workspace.revertableBlockAccess, sapi.World, originPos);
        }