public override void Perform(ushort x1, ushort y1, ushort z1, ushort x2, ushort y2, ushort z2, Player p, Level lvl, Brush brush) { for (ushort y = y1; y <= y2; y++) for (ushort z = z1; z <= z2; z++) for (ushort x = x1; x <= x2; x++) { PlaceBlock(p, lvl, x, y, z, brush); } }
public override void Perform(ushort x1, ushort y1, ushort z1, ushort x2, ushort y2, ushort z2, Player p, Level lvl, Brush brush) { while (true) { baseOp.Perform(x1, y1, z1, x2, y1, z2, p, lvl, brush); if (y1 >= lvl.Height || Math.Abs(x2 - x1) <= 1 || Math.Abs(z2 - z1) <= 1) break; x1++; x2--; z1++; z2--; y1 = (ushort)(y1 + yDir); } }
public override void Perform(ushort x1, ushort y1, ushort z1, ushort x2, ushort y2, ushort z2, Player p, Level lvl, Brush brush) { int lenX = (x2 - x1 + 1), lenY = (y2 - y1 + 1); QuadY(y1, x1, z1, x2, z2, p, lvl, brush); QuadY(y2, x1, z1, x2, z2, p, lvl, brush); if (lenY > 2) { QuadX(x1, (ushort)(y1 + 1), z1, (ushort)(y2 - 1), z2, p, lvl, brush); QuadX(x2, (ushort)(y1 + 1), z1, (ushort)(y2 - 1), z2, p, lvl, brush); } if (lenX > 2 && lenY > 2) { QuadZ(z1, (ushort)(x1 + 1), (ushort)(y1 + 1), (ushort)(x2 - 1), (ushort)(y2 - 1), p, lvl, brush); QuadZ(z2, (ushort)(x1 + 1), (ushort)(y1 + 1), (ushort)(x2 - 1), (ushort)(y2 - 1), p, lvl, brush); } }
public override void Perform(ushort x1, ushort y1, ushort z1, ushort x2, ushort y2, ushort z2, Player p, Level lvl, Brush brush) { /* Courtesy of fCraft's awesome Open-Source'ness :D */ double cx = (x1 + x2) / 2.0, cy = (y1 + y2) / 2.0, cz = (z1 + z2) / 2.0; double rx = (x2 - x1) / 2.0 + 0.25, ry = (y2 - y1) / 2.0 + 0.25, rz = (z2 - z1) / 2.0 + 0.25; double rx2 = 1 / (rx * rx), ry2 = 1 / (ry * ry), rz2 = 1 / (rz * rz); for (ushort yy = y1; yy <= y2; yy++) for (ushort zz = z1; zz <= z2; zz++) for (ushort xx = x1; xx <= x2; xx++) { double dx = xx - cx, dy = yy - cy, dz = zz - cz; if ((dx * dx) * rx2 + (dy * dy) * ry2 + (dz * dz) * rz2 <= 1) PlaceBlock(p, lvl, xx, yy, zz, brush); } }
public override void Perform(ushort x1, ushort y1, ushort z1, ushort x2, ushort y2, ushort z2, Player p, Level lvl, Brush brush) { for (ushort y = y1; y <= y2; y++) for (ushort z = z1; z <= z2; z++) { int i = (y & 1) == 0 ? 0 : 1; if ((z & 1) == 0) i++; for (ushort x = x1; x <= x2; x++) { if ((i & 1) == 0) PlaceBlock(p, lvl, x, y, z, brush); else PlaceBlock(p, lvl, x, y, z, Block.air, 0); i++; } } }
public override void Perform(ushort x1, ushort y1, ushort z1, ushort x2, ushort y2, ushort z2, Player p, Level lvl, Brush brush) { ReplaceBlock[] toReplace = ToReplace; ReplaceBlock target = Target; for (ushort y = y1; y <= y2; y++) for (ushort z = z1; z <= z2; z++) for (ushort x = x1; x <= x2; x++) { byte tile = lvl.GetTile(x, y, z), extTile = 0; if (tile == Block.custom_block) extTile = lvl.GetExtTile(x, y, z); for (int i = 0; i < toReplace.Length; i++) { ReplaceBlock block = toReplace[i]; if (tile != block.Type || (tile == Block.custom_block && extTile != block.ExtType)) { PlaceBlock(p, lvl, x, y, z, target.Type, target.ExtType); break; } } } }
public override void Perform(ushort x1, ushort y1, ushort z1, ushort x2, ushort y2, ushort z2, Player p, Level lvl, Brush brush) { /* Courtesy of fCraft's awesome Open-Source'ness :D */ double cx = (x1 + x2) / 2.0, cy = (y1 + y2) / 2.0, cz = (z1 + z2) / 2.0; double rx = (x2 - x1) / 2.0 + 0.25, ry = (y2 - y1) / 2.0 + 0.25, rz = (z2 - z1) / 2.0 + 0.25; double rx2 = 1 / (rx * rx), ry2 = 1 / (ry * ry), rz2 = 1 / (rz * rz); double smallrx2 = 1 / ((rx - 1) * (rx - 1)); double smallry2 = 1 / ((ry - 1) * (ry - 1)); double smallrz2 = 1 / ((rz - 1) * (rz - 1)); for (ushort yy = y1; yy <= y2; yy++) for (ushort zz = z1; zz <= z2; zz++) for (ushort xx = x1; xx <= x2; xx++) { double dx = xx - cx, dy = yy - cy, dz = zz - cz; dx *= dx; dy *= dy; dz *= dz; bool inRange = dx * rx2 + dy * ry2 + dz * rz2 <= 1; if (inRange && (dx * smallrx2 + dy * smallry2 + dz * smallrz2 > 1)) PlaceBlock(p, lvl, xx, yy, zz, brush); } }
public static bool DoDrawOp(DrawOp op, Brush brush, Player p, ushort x1, ushort y1, ushort z1, ushort x2, ushort y2, ushort z2) { int affected = 0; if (!op.CanDraw(x1, y1, z1, x2, y2, z2, p, out affected)) return false; Player.SendMessage(p, op.Name + ": affecting up to an estimated " + affected + " blocks"); bool needReveal = op.DetermineDrawOpMethod(p.level, affected); op.Perform(x1, y1, z1, x2, y2, z2, p, p.level, brush); if (needReveal) { foreach (Player pl in Player.players) { if (pl.level.name.ToLower() == p.level.name.ToLower()) Command.all.Find("reveal").Use(p, pl.name); } } return true; }
protected void PlaceBlock(Player p, Level lvl, ushort x, ushort y, ushort z, Brush brush) { byte type = brush.NextBlock(); if (type == Block.Zero) return; PlaceBlock(p, lvl, x, y, z, type, brush.NextExtBlock()); }
public abstract void Perform(ushort x1, ushort y1, ushort z1, ushort x2, ushort y2, ushort z2, Player p, Level lvl, Brush brush);
public PyramidReverseDrawOp() : base(new CuboidDrawOp(), -1) { wallOp = new CuboidWallsDrawOp(); airBrush = new SolidBrush(Block.air, 0); }
protected void QuadX(ushort x, ushort y1, ushort z1, ushort y2, ushort z2, Player p, Level lvl, Brush brush) { for (ushort y = y1; y <= y2; y++) for (ushort z = z1; z <= z2; z++) { PlaceBlock(p, lvl, x, y, z, brush); } }
public override void Perform(ushort x1, ushort y1, ushort z1, ushort x2, ushort y2, ushort z2, Player p, Level lvl, Brush brush) { int lenX = (x2 - x1 + 1); QuadX(x1, y1, z1, y2, z2, p, lvl, brush); QuadX(x2, y1, z1, y2, z2, p, lvl, brush); if (lenX > 2) { QuadZ(z1, (ushort)(x1 + 1), y1, (ushort)(x2 - 1), y2, p, lvl, brush); QuadZ(z2, (ushort)(x1 + 1), y1, (ushort)(x2 - 1), y2, p, lvl, brush); } }
protected void QuadZ(ushort z, ushort x1, ushort y1, ushort x2, ushort y2, Player p, Level lvl, Brush brush) { for (ushort y = y1; y <= y2; y++) for (ushort x = x1; x <= x2; x++) { PlaceBlock(p, lvl, x, y, z, brush); } }
protected void QuadY(ushort y, ushort x1, ushort z1, ushort x2, ushort z2, Player p, Level lvl, Brush brush) { for (ushort z = z1; z <= z2; z++) for (ushort x = x1; x <= x2; x++) { PlaceBlock(p, lvl, x, y, z, brush); } }