Esempio n. 1
0
        protected override bool DoDraw(Player p, Vec3S32[] marks, object state, ExtBlock block)
        {
            DrawArgs dArgs = (DrawArgs)state;
            ushort   x = (ushort)marks[0].X, y = (ushort)marks[0].Y, z = (ushort)marks[0].Z;
            ExtBlock old = p.level.GetBlock(x, y, z);

            if (!CommandParser.IsBlockAllowed(p, "fill over", old))
            {
                return(false);
            }

            if (dArgs.Mode == DrawMode.volcano)
            {
                dArgs.Mode = Calc2DFill(p, marks);
            }
            FillDrawOp op = (FillDrawOp)dArgs.Op;

            op.Positions = FillDrawOp.FloodFill(p, p.level.PosToInt(x, y, z), old, dArgs.Mode);
            int count = op.Positions.Count;

            bool confirmed = IsConfirmed(dArgs.Message), success = true;

            if (count < p.group.DrawLimit && count > p.level.ReloadThreshold && !confirmed)
            {
                Player.Message(p, "This fill would affect {0} blocks.", count);
                Player.Message(p, "If you still want to fill, type %T/Fill {0} confirm", dArgs.Message);
            }
            else
            {
                success = base.DoDraw(p, marks, state, block);
            }

            op.Positions = null;
            return(success);
        }
Esempio n. 2
0
        protected override bool DoDraw(Player p, Vec3S32[] marks,
                                       object state, byte block, byte extBlock)
        {
            DrawArgs dArgs = (DrawArgs)state;
            ushort   x = (ushort)marks[0].X, y = (ushort)marks[0].Y, z = (ushort)marks[0].Z;
            byte     oldBlock = p.level.GetTile(x, y, z), oldExtBlock = 0;

            if (oldBlock == Block.custom_block)
            {
                oldExtBlock = p.level.GetExtTile(x, y, z);
            }

            if (!Block.canPlace(p, oldBlock) && !Block.BuildIn(oldBlock))
            {
                Formatter.MessageBlock(p, "fill over ", oldBlock); return(false);
            }

            FillDrawOp op = (FillDrawOp)dArgs.Op;

            op.Positions = FloodFill(p, p.level.PosToInt(x, y, z), oldBlock, oldExtBlock, dArgs.Mode);
            int count = op.Positions.Count;

            bool confirmed = IsConfirmed(dArgs.Message), success = true;

            if (count < p.group.maxBlocks && count > Server.DrawReloadLimit && !confirmed)
            {
                Player.Message(p, "This fill would affect {0} blocks.", count);
                Player.Message(p, "If you still want to fill, type %T/fill {0} confirm", dArgs.Message);
            }
            else
            {
                success = base.DoDraw(p, marks, state, block, extBlock);
            }

            op.Positions = null;
            return(success);
        }
Esempio n. 3
0
        protected override void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type, byte extType)
        {
            p.ClearBlockchange();
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            byte     oldType = p.level.GetTile(x, y, z), oldExtType = 0;

            if (oldType == Block.custom_block)
            {
                oldExtType = p.level.GetExtTile(x, y, z);
            }
            p.RevertBlock(x, y, z);
            GetRealBlock(type, extType, p, ref cpos);

            if (cpos.type == oldType)
            {
                if (cpos.type != Block.custom_block)
                {
                    Player.SendMessage(p, "Cannot fill with the same type."); return;
                }
                if (cpos.extType == oldExtType)
                {
                    Player.SendMessage(p, "Cannot fill with the same type."); return;
                }
            }
            if (!Block.canPlace(p, oldType) && !Block.BuildIn(oldType))
            {
                Player.SendMessage(p, "Cannot fill with that."); return;
            }

            SparseBitSet bits = new SparseBitSet(p.level.Width, p.level.Height, p.level.Length);
            List <int>   buffer = new List <int>(), origins = new List <int>();

            FloodFill(p, x, y, z, oldType, oldExtType, cpos.mode, bits, buffer, origins, 0);

            int totalFill = origins.Count;

            for (int i = 0; i < totalFill; i++)
            {
                int pos = origins[i];
                p.level.IntToPos(pos, out x, out y, out z);
                FloodFill(p, x, y, z, oldType, oldExtType, cpos.mode, bits, buffer, origins, 0);
                totalFill = origins.Count;
            }

            FillDrawOp op = new FillDrawOp();

            op.Positions = buffer;
            int   brushOffset = cpos.mode == DrawMode.normal ? 0 : 1;
            Brush brush       = GetBrush(p, cpos, brushOffset);

            if (brush == null)
            {
                return;
            }
            if (!DrawOp.DoDrawOp(op, brush, p, cpos.x, cpos.y, cpos.z, cpos.x, cpos.y, cpos.z))
            {
                return;
            }
            bits.Clear();
            op.Positions = null;

            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }