Beispiel #1
0
        public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush)
        {
            Vec3U16   p1       = marks[0];
            CopyState state    = CopyState;
            bool      pasteAir = state.PasteAir;
            // Adjust for the fact that paste origin may be outside the map.
            short offX = (short)p1.X, offY = (short)p1.Y, offZ = (short)p1.Z;

            for (int i = 0; i < state.Blocks.Length; i++)
            {
                ushort locX, locY, locZ;
                byte   b = state.Blocks[i], extB = state.ExtBlocks[i];
                state.GetCoords(i, out locX, out locY, out locZ);

                ushort x = (ushort)(locX + offX), y = (ushort)(locY + offY), z = (ushort)(locZ + offZ);
                byte   type = lvl.GetTile(x, y, z), extType = 0;
                if (type == Block.custom_block)
                {
                    extType = lvl.GetExtTile(x, y, z);
                }

                bool place = lvl.InBound(x, y, z) && (b != type || (b == Block.custom_block && extB != extType));
                if ((b != Block.air || pasteAir) && place)
                {
                    PlaceBlock(p, lvl, x, y, z, b, extB);
                }
            }
        }
Beispiel #2
0
        public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush)
        {
            Vec3U16   p1       = marks[0];
            CopyState state    = CopyState;
            bool      pasteAir = state.PasteAir;

            ExtBlock[] include = Include, exclude = Exclude;
            // Adjust for the fact that paste origin may be outside the map.
            short offX = (short)p1.X, offY = (short)p1.Y, offZ = (short)p1.Z;

            for (int i = 0; i < state.Blocks.Length; i++)
            {
                ushort locX, locY, locZ;
                byte   b = state.Blocks[i], extB = state.ExtBlocks[i];
                state.GetCoords(i, out locX, out locY, out locZ);

                ushort x = (ushort)(locX + offX), y = (ushort)(locY + offY), z = (ushort)(locZ + offZ);
                byte   type = lvl.GetTile(x, y, z), extType = 0;
                if (type == Block.custom_block)
                {
                    extType = lvl.GetExtTile(x, y, z);
                }

                bool place = lvl.InBound(x, y, z) && (b != type || (b == Block.custom_block && extB != extType));
                if (!place || (b == Block.air && !pasteAir))
                {
                    continue;
                }

                if (exclude != null)
                {
                    for (int j = 0; j < exclude.Length; j++)
                    {
                        ExtBlock block = exclude[j];
                        if (b == block.Type && (b != Block.custom_block || extB == block.ExtType))
                        {
                            place = false; break;
                        }
                    }
                    if (!place)
                    {
                        continue;
                    }
                    PlaceBlock(p, lvl, x, y, z, b, extB);
                }

                if (include != null)
                {
                    for (int j = 0; j < include.Length; j++)
                    {
                        ExtBlock block = include[j];
                        if (b == block.Type && (b != Block.custom_block || extB == block.ExtType))
                        {
                            PlaceBlock(p, lvl, x, y, z, b, extB); break;
                        }
                    }
                }
            }
        }
Beispiel #3
0
        public override void Perform(Vec3S32[] marks, Brush brush, Action <DrawOpBlock> output)
        {
            CopyState state    = CopyState;
            bool      pasteAir = state.PasteAir;

            ExtBlock[] include = Include, exclude = Exclude;
            // Adjust for the fact that paste origin may be outside the map.
            int x1 = marks[0].X, y1 = marks[0].Y, z1 = marks[0].Z;

            for (int i = 0; i < state.Blocks.Length; i++)
            {
                ushort locX, locY, locZ;
                byte   b = state.Blocks[i], extB = state.ExtBlocks[i];
                state.GetCoords(i, out locX, out locY, out locZ);

                ushort x = (ushort)(locX + x1), y = (ushort)(locY + y1), z = (ushort)(locZ + z1);
                if ((b == Block.air && !pasteAir) || !Level.InBound(x, y, z))
                {
                    continue;
                }

                if (exclude != null)
                {
                    bool place = true;
                    for (int j = 0; j < exclude.Length; j++)
                    {
                        ExtBlock block = exclude[j];
                        if (b == block.Block && (b != Block.custom_block || extB == block.Ext))
                        {
                            place = false; break;
                        }
                    }
                    if (!place)
                    {
                        continue;
                    }
                    output(Place(x, y, z, b, extB));
                }

                if (include != null)
                {
                    for (int j = 0; j < include.Length; j++)
                    {
                        ExtBlock block = include[j];
                        if (b == block.Block && (b != Block.custom_block || extB == block.Ext))
                        {
                            output(Place(x, y, z, b, extB)); break;
                        }
                    }
                }
            }
        }
Beispiel #4
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);
        }
Beispiel #5
0
        public override void Perform(Vec3S32[] marks, Brush brush, Action <DrawOpBlock> output)
        {
            CopyState state    = CopyState;
            bool      pasteAir = state.PasteAir;
            // Adjust for the fact that paste origin may be outside the map.
            int x1 = marks[0].X, y1 = marks[0].Y, z1 = marks[0].Z;

            for (int i = 0; i < state.Blocks.Length; i++)
            {
                ushort locX, locY, locZ;
                byte   b = state.Blocks[i], extB = state.ExtBlocks[i];
                state.GetCoords(i, out locX, out locY, out locZ);

                ushort x = (ushort)(locX + x1), y = (ushort)(locY + y1), z = (ushort)(locZ + z1);
                if ((b != Block.air || pasteAir) && Level.InBound(x, y, z))
                {
                    output(Place(x, y, z, b, extB));
                }
            }
        }