示例#1
0
        public override void Use(Player p, string message)
        {
            if (p == null)
            {
                MessageInGameOnly(p); return;
            }
            Vec3U16 click = p.lastClick;
            ushort  value;

            if (message.IndexOf(' ') != -1)
            {
                string[] args = message.ToLower().Split(' ');
                if (args.Length != 3)
                {
                    Help(p); return;
                }

                for (int i = 0; i < 3; i++)
                {
                    if (args[i] == "x" || args[i] == "y" || args[i] == "z")
                    {
                        // use the last value
                    }
                    else if (ushort.TryParse(args[i], out value))
                    {
                        if (i == 0)
                        {
                            click.X = value;
                        }
                        else if (i == 1)
                        {
                            click.Y = value;
                        }
                        else
                        {
                            click.Z = value;
                        }
                    }
                    else
                    {
                        Player.SendMessage(p, "\"" + args[i] + "\" was not valid"); return;
                    }
                }
            }

            click = Vec3U16.ClampToBounds(click.X, click.Y, click.Z, p.level);
            p.ManualChange(click.X, click.Y, click.Z, 0, Block.rock);
            Player.SendMessage(p, "Clicked &b(" + click.X + ", " + click.Y + ", " + click.Z + ")");
        }
示例#2
0
        public override void Use(Player p, string message)
        {
            byte   type = Block.Zero, extType = 0;
            ushort x = (ushort)(p.pos[0] / 32);
            ushort y = (ushort)((p.pos[1] / 32) - 1);
            ushort z = (ushort)(p.pos[2] / 32);

            try {
                string[] parts = message.Split(' ');
                switch (parts.Length)
                {
                case 1: type = message == "" ? Block.rock :
                               DrawCmd.GetBlock(p, parts[0], out extType); break;

                case 3:
                    type = Block.rock;
                    x    = Convert.ToUInt16(parts[0]);
                    y    = Convert.ToUInt16(parts[1]);
                    z    = Convert.ToUInt16(parts[2]);
                    break;

                case 4:
                    type = DrawCmd.GetBlock(p, parts[0], out extType);
                    x    = Convert.ToUInt16(parts[1]);
                    y    = Convert.ToUInt16(parts[2]);
                    z    = Convert.ToUInt16(parts[3]);
                    break;

                default: Player.SendMessage(p, "Invalid number of parameters"); return;
                }
            } catch {
                Player.SendMessage(p, "Invalid parameters"); return;
            }

            if (type == Block.Zero)
            {
                return;
            }
            if (!Block.canPlace(p, type))
            {
                Player.SendMessage(p, "Cannot place that block type."); return;
            }
            Vec3U16 P = Vec3U16.ClampToBounds(x, y, z, p.level);

            p.level.UpdateBlock(p, P.X, P.Y, P.Z, type, extType);
            Player.SendMessage(p, "A block was placed at (" + P.X + ", " + P.Y + ", " + P.Z + ").");
        }