bool DoReplace(Player p, Vec3S32[] marks, object state, byte type, byte extType) { string[] args = ((string)state).SplitSpaces(3); byte extBlock = 0; int block = DrawCmd.GetBlockIfAllowed(p, args[0], out extBlock); if (block == -1) { return(false); } BrushFactory factory = BrushFactory.Find(args[1]); string brushMessage = args.Length > 2 ? args[2] : ""; BrushArgs bArgs = new BrushArgs(p, brushMessage, type, extType); Brush brush = factory.Construct(bArgs); if (brush == null) { return(false); } DrawOp op = null; if (ReplaceNot) { op = new ReplaceNotDrawOp((byte)block, extBlock); } else { op = new ReplaceDrawOp((byte)block, extBlock); } return(DrawOp.DoDrawOp(op, brush, p, marks)); }
void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); CatchPos cpos = (CatchPos)p.blockchangeObject; type = type < 128 ? p.bindings[type] : type; string[] parts = cpos.message.Split(trimChars, 3); if (parts.Length < 2) { Help(p); return; } byte extTile = 0; byte tile = DrawCmd.GetBlock(p, parts[0], out extTile); if (tile == Block.Zero) { return; } string brushName = CmdBrush.FindBrush(parts[1]); if (brushName == null) { Player.SendMessage(p, "No brush found with name \"" + parts[1] + "\"."); Player.SendMessage(p, "Available brushes: " + CmdBrush.AvailableBrushes); return; } string brushMessage = parts.Length > 2 ? parts[2].ToLower() : ""; BrushArgs args = new BrushArgs(p, brushMessage, type, extType); Brush brush = Brush.Brushes[brushName](args); if (brush == null) { return; } DrawOp drawOp = null; if (ReplaceNot) { drawOp = new ReplaceNotDrawOp(tile, extTile); } else { drawOp = new ReplaceDrawOp(tile, extTile); } if (!DrawOp.DoDrawOp(drawOp, brush, p, cpos.x, cpos.y, cpos.z, x, y, z)) { return; } if (p.staticCommands) { p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); } }
public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); CatchPos cpos = (CatchPos)p.blockchangeObject; ushort x1 = Math.Min(cpos.x, x), x2 = Math.Max(cpos.x, x); ushort y1 = Math.Min(cpos.y, y), y2 = Math.Max(cpos.y, y); ushort z1 = Math.Min(cpos.z, z), z2 = Math.Max(cpos.z, z); ReplaceNotDrawOp drawOp = new ReplaceNotDrawOp(); drawOp.ToReplace = toAffect; drawOp.Target = target; if (!DrawOp.DoDrawOp(drawOp, null, p, x1, y1, z1, x2, y2, z2)) return; if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); }
protected override DrawOp GetDrawOp(DrawArgs dArgs) { string[] args = dArgs.Message.SplitSpaces(3); Player p = dArgs.Player; if (args.Length < 2) { Help(p); return(null); } string replaceCmd = ReplaceNot ? "ReplaceNot" : "Replace"; if (!p.CanUse(replaceCmd) || !p.CanUse("Brush")) { p.Message("You cannot use /brush and/or /" + replaceCmd + ", so therefore cannot use this command."); return(null); } BlockID target; if (!CommandParser.GetBlockIfAllowed(p, args[0], out target)) { return(null); } BrushFactory factory = BrushFactory.Find(args[1]); if (factory == null) { p.Message("No brush found with name \"{0}\".", args[1]); CmdBrush.List(p); return(null); } DrawOp op = null; if (ReplaceNot) { op = new ReplaceNotDrawOp(target); } else { op = new ReplaceDrawOp(target); } return(op); }