예제 #1
0
        CopyState RotateX(CopyState state)
        {
            CopyState newState = new CopyState(state.X, state.Y, state.Z,
                                               state.Width, state.Length, state.Height);

            byte[] blocks  = state.Blocks, extBlocks = state.ExtBlocks;
            int    oldMaxZ = state.Length - 1;

            for (int i = 0; i < blocks.Length; i++)
            {
                ushort x, y, z;
                state.GetCoords(i, out x, out y, out z);
                newState.Set(x, oldMaxZ - z, y, blocks[i], extBlocks[i]);
            }
            newState.SetOrigin(state.OriginX, state.Y + (state.OppositeOriginZ - state.Z),
                               state.Z + (state.OriginY - state.Y));
            return(newState);
        }
예제 #2
0
        void DoCopyMark(Player p, Vec3S32[] m, int i, object state, BlockID block)
        {
            CopyArgs cArgs = (CopyArgs)state;

            if (i == 2)
            {
                CopyState copy = p.CurrentCopy;
                copy.Offset.X = copy.OriginX - m[i].X;
                copy.Offset.Y = copy.OriginY - m[i].Y;
                copy.Offset.Z = copy.OriginZ - m[i].Z;

                p.Message("Set offset of where to paste from.");
                CompleteCopy(p, m, cArgs);
                return;
            }
            if (i != 1)
            {
                return;
            }

            Vec3S32 min = Vec3S32.Min(m[0], m[1]), max = Vec3S32.Max(m[0], m[1]);
            ushort  minX = (ushort)min.X, minY = (ushort)min.Y, minZ = (ushort)min.Z;
            ushort  maxX = (ushort)max.X, maxY = (ushort)max.Y, maxZ = (ushort)max.Z;

            CopyState cState = new CopyState(minX, minY, minZ, maxX - minX + 1,
                                             maxY - minY + 1, maxZ - minZ + 1);

            cState.OriginX = m[0].X; cState.OriginY = m[0].Y; cState.OriginZ = m[0].Z;

            int index = 0; cState.UsedBlocks = 0;

            cState.PasteAir = cArgs.air;

            for (ushort y = minY; y <= maxY; ++y)
            {
                for (ushort z = minZ; z <= maxZ; ++z)
                {
                    for (ushort x = minX; x <= maxX; ++x)
                    {
                        block = p.level.GetBlock(x, y, z);
                        if (!p.group.Blocks[block])
                        {
                            index++; continue;
                        }

                        if (block != Block.Air || cState.PasteAir)
                        {
                            cState.UsedBlocks++;
                        }
                        cState.Set(block, index);
                        index++;
                    }
                }
            }

            if (cState.UsedBlocks > p.group.DrawLimit)
            {
                p.Message("You tried to copy {0} blocks. You cannot copy more than {1} blocks.",
                          cState.UsedBlocks, p.group.DrawLimit);
                cState.Clear(); cState = null;
                p.ClearSelection();
                return;
            }

            cState.CopySource = "level " + p.level.name;
            p.CurrentCopy     = cState;

            p.Message("Copied &a{0} &Sblocks, origin at ({1}, {2}, {3}) corner", cState.UsedBlocks,
                      cState.OriginX == cState.X ? "Min" : "Max",
                      cState.OriginY == cState.Y ? "Min" : "Max",
                      cState.OriginZ == cState.Z ? "Min" : "Max");
            if (!cState.PasteAir)
            {
                p.Message("To also copy air blocks, use &T/Copy Air");
            }

            if (cArgs.offsetIndex != -1)
            {
                p.Message("Place a block to determine where to paste from");
            }
            else
            {
                CompleteCopy(p, m, cArgs);
            }
        }
예제 #3
0
        void DoCopyMark(Player p, Vec3S32[] m, int i, object state, ExtBlock block)
        {
            if (i == 2)
            {
                CopyState copy = p.CopySlots[p.CurrentCopySlot];
                copy.Offset.X = copy.OriginX - m[i].X;
                copy.Offset.Y = copy.OriginY - m[i].Y;
                copy.Offset.Z = copy.OriginZ - m[i].Z;
                Player.Message(p, "Set offset of where to paste from.");
                return;
            }
            if (i != 1)
            {
                return;
            }

            CopyArgs cArgs = (CopyArgs)state;
            Vec3S32  min = Vec3S32.Min(m[0], m[1]), max = Vec3S32.Max(m[0], m[1]);
            ushort   minX = (ushort)min.X, minY = (ushort)min.Y, minZ = (ushort)min.Z;
            ushort   maxX = (ushort)max.X, maxY = (ushort)max.Y, maxZ = (ushort)max.Z;

            CopyState cState = new CopyState(minX, minY, minZ, maxX - minX + 1,
                                             maxY - minY + 1, maxZ - minZ + 1);

            cState.OriginX = m[0].X; cState.OriginY = m[0].Y; cState.OriginZ = m[0].Z;

            int index = 0; cState.UsedBlocks = 0;

            cState.PasteAir = cArgs.air;

            for (ushort y = minY; y <= maxY; ++y)
            {
                for (ushort z = minZ; z <= maxZ; ++z)
                {
                    for (ushort x = minX; x <= maxX; ++x)
                    {
                        block = p.level.GetBlock(x, y, z);
                        if (!p.group.Blocks[block.BlockID])
                        {
                            index++; continue;
                        }                                                  // TODO: will need to fix this when extblock permissions

                        if (block.BlockID != Block.Air || cState.PasteAir)
                        {
                            cState.UsedBlocks++;
                        }
                        cState.Set(block, index);
                        index++;
                    }
                }
            }

            if (cState.UsedBlocks > p.group.DrawLimit)
            {
                Player.Message(p, "You tried to copy {0} blocks. You cannot copy more than {1} blocks.",
                               cState.UsedBlocks, p.group.DrawLimit);
                cState.Clear(); cState = null;
                p.ClearSelection();
                return;
            }

            cState.CopySource = "level " + p.level.name;
            p.SetCurrentCopy(cState);
            if (cArgs.cut)
            {
                DrawOp op = new CuboidDrawOp();
                op.Flags = BlockDBFlags.Cut;
                Brush brush = new SolidBrush(ExtBlock.Air);
                DrawOpPerformer.Do(op, brush, p, new Vec3S32[] { min, max }, false);
            }

            Player.Message(p, "Copied &a{0} %Sblocks, origin at ({1}, {2}, {3}) corner", cState.UsedBlocks,
                           cState.OriginX == cState.X ? "Min" : "Max",
                           cState.OriginY == cState.Y ? "Min" : "Max",
                           cState.OriginZ == cState.Z ? "Min" : "Max");
            if (!cState.PasteAir)
            {
                Player.Message(p, "To also copy air blocks, use %T/Copy Air");
            }
            if (cArgs.offsetIndex != -1)
            {
                Player.Message(p, "Place a block to determine where to paste from");
            }
        }