public override void Use(Player p, string message) { message = message.ToLower(); string[] parts = message.SplitSpaces(); DrawArgs dArgs = new DrawArgs(); dArgs.Message = message; dArgs.Player = p; dArgs.Mode = GetMode(parts); dArgs.Op = GetDrawOp(dArgs); if (dArgs.Op == null) { return; } // Validate the brush syntax is correct BrushFactory factory = MakeBrush(dArgs); BrushArgs bArgs = new BrushArgs(p, dArgs.BrushArgs, dArgs.Block); if (!factory.Validate(bArgs)) { return; } Player.Message(p, PlaceMessage); p.MakeSelection(MarksCount, "Selecting region for %S" + dArgs.Op.Name, dArgs, DoDraw); }
public override void Use(Player p, string message, CommandData data) { BrushArgs args = new BrushArgs(p, message, Block.Air); Brush brush = BrushFactory.Find("Replace").Construct(args); if (brush == null) { return; } Vec3S32 max = new Vec3S32(p.level.Width - 1, p.level.Height - 1, p.level.Length - 1); Vec3S32[] marks = new Vec3S32[] { Vec3S32.Zero, max }; MeasureDrawOp measure = new MeasureDrawOp(); measure.Setup(p, p.level, marks); measure.Perform(marks, brush, null); if (measure.Total > p.group.DrawLimit) { p.Message("You tried to replace " + measure.Total + " blocks."); p.Message("You cannot draw more than " + p.group.DrawLimit + "."); return; } DrawOp op = new CuboidDrawOp(); op.AffectedByTransform = false; if (!DrawOpPerformer.Do(op, brush, p, marks, false)) { return; } p.Message("&4/replaceall finished!"); }
protected static Brush GetBrush(Player p, CatchPos cpos, int usedFromEnd, Func <BrushArgs, Brush> constructor = null) { int end = cpos.message.Length; string brushMsg = ""; for (int i = 0; i < usedFromEnd; i++) { end = cpos.message.LastIndexOf(' ', end - 1); if (end == -1) { break; } } if (end >= 0) { brushMsg = cpos.message.Substring(0, end); } if (brushMsg == "") { brushMsg = p.DefaultBrushArgs; } if (constructor == null) { constructor = Brush.Brushes[p.BrushName]; } BrushArgs args = new BrushArgs(p, brushMsg, cpos.type, cpos.extType); return(constructor(args)); }
bool ValidateArgs(Player p, string[] args) { if (args.Length < 2) { Help(p); return(false); } byte extBlock = 0; int block = DrawCmd.GetBlockIfAllowed(p, args[0], out extBlock); if (block == -1) { return(false); } BrushFactory factory = BrushFactory.Find(args[1]); if (factory == null) { Player.Message(p, "No brush found with name \"{0}\".", args[1]); Player.Message(p, "Available brushes: " + BrushFactory.Available); return(false); } string brushMessage = args.Length > 2 ? args[2] : ""; byte held, extHeld; held = p.GetActualHeldBlock(out extHeld); BrushArgs bArgs = new BrushArgs(p, brushMessage, held, extHeld); return(factory.Validate(bArgs)); }
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)); }
public override void Use(Player p, string message) { if (Player.IsSuper(p)) { MessageInGameOnly(p); return; } message = message.ToLower(); string[] parts = message.Split(' '); DrawArgs dArgs = default(DrawArgs); dArgs.Message = message; dArgs.Player = p; dArgs.Mode = GetMode(parts); dArgs.Op = GetDrawOp(dArgs); if (dArgs.Op == null) { return; } // Validate the brush syntax is correct int offset = 0; BrushFactory factory = BrushFactory.Find(GetBrush(p, dArgs, ref offset)); BrushArgs bArgs = GetBrushArgs(dArgs, offset); if (!factory.Validate(bArgs)) { return; } Player.Message(p, PlaceMessage); p.MakeSelection(MarksCount, dArgs, DoDraw); }
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); } }
bool DoReplace(Player p, Vec3S32[] marks, object state, byte type, byte extType) { BrushArgs args = new BrushArgs(p, (string)state, type, extType); string name = ReplaceNot ? "replacenot" : "replace"; Brush brush = BrushFactory.Find(name).Construct(args); if (brush == null) { return(false); } DrawOp drawOp = new CuboidDrawOp(); return(DrawOp.DoDrawOp(drawOp, brush, p, marks)); }
static Brush ParseBrush(string raw, Player p, ExtBlock block) { string[] parts = raw.SplitSpaces(2); BrushFactory brush = BrushFactory.Find(parts[0]); if (brush == null) { Player.Message(p, "No brush found with name \"{0}\".", parts[0]); Player.Message(p, "Available brushes: " + BrushFactory.Available); return(null); } string brushArgs = parts.Length >= 2 ? parts[1].ToLower() : ""; BrushArgs args = new BrushArgs(p, brushArgs, block); return(brush.Construct(args)); }
static Brush ParseBrush(string brushMsg, Player p, byte type, byte extType) { string[] parts = brushMsg.Split(trimChars, 2); string brushName = CmdBrush.FindBrush(parts[0]); if (brushName == null) { Player.SendMessage(p, "No brush found with name \"" + parts[0] + "\"."); Player.SendMessage(p, "Available brushes: " + CmdBrush.AvailableBrushes); return(null); } string brushMessage = parts.Length >= 2 ? parts[1].ToLower() : ""; BrushArgs args = new BrushArgs(p, brushMessage, type, extType); return(Brush.Brushes[brushName](args)); }
public override void Use(Player p, string message, CommandData data) { if (p.CurrentCopy == null) { p.Message("You haven't copied anything yet"); return; } BrushArgs args = new BrushArgs(p, message, Block.Air); if (!BrushFactory.Find("Paste").Validate(args)) { return; } p.Message("Place a block in the corner of where you want to paste."); p.MakeSelection(1, "Selecting location for %SPaste", args, DoPaste); }
public override void Use(Player p, string message) { if (p.CurrentCopySlot >= p.CopySlots.Count || p.CopySlots[p.CurrentCopySlot] == null) { Player.Message(p, "You haven't copied anything yet"); return; } BrushArgs args = new BrushArgs(p, message, ExtBlock.Air); Brush brush = BrushFactory.Find("paste").Construct(args); if (brush == null) { return; } Player.Message(p, "Place a block in the corner of where you want to paste."); p.MakeSelection(1, "Selecting location for %SPaste", brush, DoPaste); }
public override void Use(Player p, string message) { string brushMsg = message.ToLower(); byte block, extBlock; block = p.GetActualHeldBlock(out extBlock); BrushArgs args = new BrushArgs(p, brushMsg, block, extBlock); string name = ReplaceNot ? "replacenot" : "replace"; if (!BrushFactory.Find(name).Validate(args)) { return; } Player.Message(p, "Place two blocks to determine the edges."); p.MakeSelection(2, message.ToLower(), DoReplace); }
protected virtual bool DoDraw(Player p, Vec3S32[] marks, object state, byte block, byte extBlock) { DrawArgs dArgs = (DrawArgs)state; dArgs.Block = block; dArgs.ExtBlock = extBlock; GetMarks(dArgs, ref marks); if (marks == null) { return(false); } int offset = 0; BrushFactory factory = BrushFactory.Find(GetBrush(p, dArgs, ref offset)); BrushArgs bArgs = GetBrushArgs(dArgs, offset); Brush brush = factory.Construct(bArgs); return(brush != null && DrawOp.DoDrawOp(dArgs.Op, brush, p, marks)); }
bool DoPaste(Player p, Vec3S32[] m, object state, BlockID block) { CopyState cState = p.CurrentCopy; m[0] += cState.Offset; BrushArgs args = (BrushArgs)state; Brush brush = BrushFactory.Find("Paste").Construct(args); if (brush == null) { return(false); } PasteDrawOp op = new PasteDrawOp(); op.CopyState = cState; DrawOpPerformer.Do(op, brush, p, m); return(true); }
public override void Use(Player p, string message, CommandData data) { DrawArgs dArgs = MakeArgs(p, message); if (dArgs.Op == null) { return; } // Validate the brush syntax is correct BrushFactory factory = MakeBrush(dArgs); BrushArgs bArgs = new BrushArgs(p, dArgs.BrushArgs, dArgs.Block); if (!factory.Validate(bArgs)) { return; } p.Message(PlaceMessage); p.MakeSelection(MarksCount, "Selecting " + SelectionType + " for &S" + dArgs.Op.Name, dArgs, DoDraw); }
public override void Use(Player p, string message) { ushort x2 = (ushort)(p.level.Width - 1); ushort y2 = (ushort)(p.level.Height - 1); ushort z2 = (ushort)(p.level.Length - 1); BrushArgs args = new BrushArgs(p, message.ToLower(), 0, 0); Brush brush = BrushFactory.Find("replace").Construct(args); if (brush == null) { return; } DrawOp drawOp = new CuboidDrawOp(); if (!DrawOp.DoDrawOp(drawOp, brush, p, 0, 0, 0, x2, y2, z2)) { return; } Player.Message(p, "&4/replaceall finished!"); }
protected virtual bool DoDraw(Player p, Vec3S32[] marks, object state, BlockID block) { DrawArgs dArgs = (DrawArgs)state; dArgs.Block = block; GetMarks(dArgs, ref marks); if (marks == null) { return(false); } BrushFactory factory = MakeBrush(dArgs); BrushArgs bArgs = new BrushArgs(p, dArgs.BrushArgs, dArgs.Block); Brush brush = factory.Construct(bArgs); if (brush == null) { return(false); } DrawOpPerformer.Do(dArgs.Op, brush, p, marks); return(true); }
void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); CatchPos cpos = (CatchPos)p.blockchangeObject; BrushArgs args = new BrushArgs(p, cpos.message, type, extType); Brush brush = ReplaceNot ? ReplaceNotBrush.Process(args) : ReplaceBrush.Process(args); if (brush == null) { return; } DrawOp drawOp = new CuboidDrawOp(); 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); } }