protected override DrawOp GetDrawOp(DrawArgs dArgs) { DrawOp op = new CuboidDrawOp(); op.AffectedByTransform = false; return(op); }
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 override void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); CatchPos cpos = (CatchPos)p.blockchangeObject; GetRealBlock(type, extType, p, ref cpos); DrawOp drawOp = null; Brush brush = null; switch (cpos.solid) { case SolidType.solid: drawOp = new CuboidDrawOp(); break; case SolidType.hollow: drawOp = new CuboidHollowsDrawOp(); break; case SolidType.walls: drawOp = new CuboidWallsDrawOp(); break; case SolidType.holes: drawOp = new CuboidHolesDrawOp(); break; case SolidType.wire: drawOp = new CuboidWireframeDrawOp(); break; case SolidType.random: drawOp = new CuboidDrawOp(); brush = new RandomBrush(cpos.type, cpos.extType); break; } if (brush == null) brush = new SolidBrush(cpos.type, cpos.extType); 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); if (!DrawOp.DoDrawOp(drawOp, brush, p, x1, y1, z1, x2, y2, z2)) return; if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); }
protected override void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); CatchPos cpos = (CatchPos)p.blockchangeObject; GetRealBlock(type, extType, p, ref cpos); DrawOp op = null; Func <BrushArgs, Brush> constructor = null; switch (cpos.mode) { case DrawMode.solid: op = new CuboidDrawOp(); constructor = SolidBrush.Process; break; case DrawMode.normal: op = new CuboidDrawOp(); break; case DrawMode.hollow: op = new CuboidHollowsDrawOp(); break; case DrawMode.walls: op = new CuboidWallsDrawOp(); break; case DrawMode.holes: op = new CuboidDrawOp(); constructor = CheckeredBrush.Process; break; case DrawMode.wire: op = new CuboidWireframeDrawOp(); break; case DrawMode.random: op = new CuboidDrawOp(); constructor = RandomBrush.Process; break; } int brushOffset = cpos.mode == DrawMode.normal ? 0 : 1; Brush brush = GetBrush(p, cpos, brushOffset, constructor); if (brush == null) { return; } if (!DrawOp.DoDrawOp(op, brush, p, cpos.x, cpos.y, cpos.z, x, y, z)) { return; } if (p.staticCommands) { p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); } }
void CompleteCopy(Player p, Vec3S32[] m, CopyArgs cArgs) { if (!cArgs.cut) { return; } DrawOp op = new CuboidDrawOp(); op.Flags = BlockDBFlags.Cut; Brush brush = new SolidBrush(Block.Air); DrawOpPerformer.Do(op, brush, p, new Vec3S32[] { m[0], m[1] }, false); }
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)); }
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!"); }
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); } }
bool DoCopy(Player p, Vec3S32[] m, object state, byte type, byte extType) { CopyArgs cArgs = (CopyArgs)state; ushort minX = (ushort)Math.Min(m[0].X, m[1].X), maxX = (ushort)Math.Max(m[0].X, m[1].X); ushort minY = (ushort)Math.Min(m[0].Y, m[1].Y), maxY = (ushort)Math.Max(m[0].Y, m[1].Y); ushort minZ = (ushort)Math.Min(m[0].Z, m[1].Z), maxZ = (ushort)Math.Max(m[0].Z, m[1].Z); CopyState cState = new CopyState(minX, minY, minZ, maxX - minX + 1, maxY - minY + 1, maxZ - minZ + 1); cState.OriginX = m[0].X; cState.OriginY = m[0].Y; cState.OriginZ = m[0].Z; int index = 0; cState.UsedBlocks = 0; cState.PasteAir = cArgs.type == 2; for (ushort yy = minY; yy <= maxY; ++yy) { for (ushort zz = minZ; zz <= maxZ; ++zz) { for (ushort xx = minX; xx <= maxX; ++xx) { byte b = p.level.GetTile(xx, yy, zz), extB = 0; if (!Block.canPlace(p, b)) { index++; continue; } if (b == Block.custom_block) { extB = p.level.GetExtTile(xx, yy, zz); } if (b != Block.air || cState.PasteAir) { cState.UsedBlocks++; } cState.Blocks[index] = b; cState.ExtBlocks[index] = extB; index++; } } } if (cState.UsedBlocks > p.group.maxBlocks) { Player.Message(p, "You tried to copy {0} blocks. You cannot copy more than {1} blocks.", cState.UsedBlocks, p.group.maxBlocks); cState.Blocks = null; cState.ExtBlocks = null; cState = null; return(false); } p.CopyBuffer = cState; if (cArgs.type == 1) { DrawOp op = new CuboidDrawOp(); op.Flags = BlockDBFlags.Cut; Brush brush = new SolidBrush(Block.air, 0); Vec3S32[] marks = { new Vec3S32(minX, minY, minZ), new Vec3S32(maxX, maxY, maxZ) }; DrawOp.DoDrawOp(op, brush, p, marks, false); } string format = "Copied &a{0} %Sblocks." + (cState.PasteAir ? "" : " To also copy air blocks, use %T/copy air"); Player.Message(p, format, cState.UsedBlocks); if (cArgs.offsetIndex != -1) { Player.Message(p, "Place a block to determine where to paste from"); p.Blockchange += BlockchangeOffset; } return(false); }
void DoCopyMark(Player p, Vec3S32[] m, int i, object state, BlockID block) { if (i == 2) { CopyState copy = p.CurrentCopy; copy.Offset.X = copy.OriginX - m[i].X; copy.Offset.Y = copy.OriginY - m[i].Y; copy.Offset.Z = copy.OriginZ - m[i].Z; p.Message("Set offset of where to paste from."); return; } if (i != 1) { return; } CopyArgs cArgs = (CopyArgs)state; Vec3S32 min = Vec3S32.Min(m[0], m[1]), max = Vec3S32.Max(m[0], m[1]); ushort minX = (ushort)min.X, minY = (ushort)min.Y, minZ = (ushort)min.Z; ushort maxX = (ushort)max.X, maxY = (ushort)max.Y, maxZ = (ushort)max.Z; CopyState cState = new CopyState(minX, minY, minZ, maxX - minX + 1, maxY - minY + 1, maxZ - minZ + 1); cState.OriginX = m[0].X; cState.OriginY = m[0].Y; cState.OriginZ = m[0].Z; int index = 0; cState.UsedBlocks = 0; cState.PasteAir = cArgs.air; for (ushort y = minY; y <= maxY; ++y) { for (ushort z = minZ; z <= maxZ; ++z) { for (ushort x = minX; x <= maxX; ++x) { block = p.level.GetBlock(x, y, z); if (!p.group.Blocks[block]) { index++; continue; } if (block != Block.Air || cState.PasteAir) { cState.UsedBlocks++; } cState.Set(block, index); index++; } } } if (cState.UsedBlocks > p.group.DrawLimit) { p.Message("You tried to copy {0} blocks. You cannot copy more than {1} blocks.", cState.UsedBlocks, p.group.DrawLimit); cState.Clear(); cState = null; p.ClearSelection(); return; } cState.CopySource = "level " + p.level.name; p.CurrentCopy = cState; if (cArgs.cut) { DrawOp op = new CuboidDrawOp(); op.Flags = BlockDBFlags.Cut; Brush brush = new SolidBrush(Block.Air); DrawOpPerformer.Do(op, brush, p, new Vec3S32[] { min, max }, false); } p.Message("Copied &a{0} %Sblocks, origin at ({1}, {2}, {3}) corner", cState.UsedBlocks, cState.OriginX == cState.X ? "Min" : "Max", cState.OriginY == cState.Y ? "Min" : "Max", cState.OriginZ == cState.Z ? "Min" : "Max"); if (!cState.PasteAir) { p.Message("To also copy air blocks, use %T/Copy Air"); } if (cArgs.offsetIndex != -1) { p.Message("Place a block to determine where to paste from"); } }