mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-17 19:29:49 -04:00
Fix cuboid holes.
This commit is contained in:
parent
a98c35fbef
commit
002e114a6d
@ -91,25 +91,21 @@ namespace MCGalaxy.Commands
|
||||
|
||||
switch (cpos.solid) {
|
||||
case SolidType.solid:
|
||||
drawOp = new CuboidDrawOp();
|
||||
brush = new SolidBrush(type); break;
|
||||
drawOp = new CuboidDrawOp(); break;
|
||||
case SolidType.hollow:
|
||||
drawOp = new CuboidHollowsDrawOp();
|
||||
brush = new SolidBrush(type); break;
|
||||
drawOp = new CuboidHollowsDrawOp(); break;
|
||||
case SolidType.walls:
|
||||
drawOp = new CuboidWallsDrawOp();
|
||||
brush = new SolidBrush(type); break;
|
||||
drawOp = new CuboidWallsDrawOp(); break;
|
||||
case SolidType.holes:
|
||||
drawOp = new CuboidDrawOp();
|
||||
brush = new HolesBrush(type); break;
|
||||
drawOp = new CuboidHolesDrawOp(); break;
|
||||
case SolidType.wire:
|
||||
drawOp = new CuboidWireframeDrawOp();
|
||||
brush = new SolidBrush(type); break;
|
||||
drawOp = new CuboidWireframeDrawOp(); break;
|
||||
case SolidType.random:
|
||||
drawOp = new CuboidDrawOp();
|
||||
brush = new RandomBrush(type); break;
|
||||
}
|
||||
|
||||
if (brush == null) brush = new SolidBrush(type);
|
||||
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);
|
||||
|
@ -36,20 +36,6 @@ namespace MCGalaxy {
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class HolesBrush : Brush {
|
||||
readonly byte block;
|
||||
|
||||
public HolesBrush(byte block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
public override byte NextBlock() {
|
||||
i++;
|
||||
return (i & 1) == 0 ? Block.air : block;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class RainbowBrush : Brush {
|
||||
readonly Random rnd;
|
||||
|
||||
|
@ -35,7 +35,34 @@ namespace MCGalaxy {
|
||||
for (ushort z = z1; z <= z2; z++)
|
||||
for (ushort x = x1; x <= x2; x++)
|
||||
{
|
||||
PlaceBlock(p, lvl, x, y, z, brush);
|
||||
PlaceBlock(p, lvl, x, y, z, brush.NextBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CuboidHolesDrawOp : DrawOp {
|
||||
|
||||
public override string Name {
|
||||
get { return "Cuboid Holes"; }
|
||||
}
|
||||
|
||||
public override int GetBlocksAffected(ushort x1, ushort y1, ushort z1, ushort x2, ushort y2, ushort z2) {
|
||||
return (x2 - x1 + 1) * (y2 - y1 + 1) * (z2 - z1 + 1);
|
||||
}
|
||||
|
||||
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++) {
|
||||
byte block = (i & 1) == 0 ? brush.NextBlock() : Block.air;
|
||||
PlaceBlock(p, lvl, x, y, z, block);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -76,7 +103,7 @@ namespace MCGalaxy {
|
||||
for (ushort y = y1; y <= y2; y++)
|
||||
for (ushort z = z1; z <= z2; z++)
|
||||
{
|
||||
PlaceBlock(p, lvl, x, y, z, brush);
|
||||
PlaceBlock(p, lvl, x, y, z, brush.NextBlock());
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,7 +112,7 @@ namespace MCGalaxy {
|
||||
for (ushort z = z1; z <= z2; z++)
|
||||
for (ushort x = x1; x <= x2; x++)
|
||||
{
|
||||
PlaceBlock(p, lvl, x, y, z, brush);
|
||||
PlaceBlock(p, lvl, x, y, z, brush.NextBlock());
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,7 +121,7 @@ namespace MCGalaxy {
|
||||
for (ushort y = y1; y <= y2; y++)
|
||||
for (ushort x = x1; x <= x2; x++)
|
||||
{
|
||||
PlaceBlock(p, lvl, x, y, z, brush);
|
||||
PlaceBlock(p, lvl, x, y, z, brush.NextBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -140,24 +167,24 @@ namespace MCGalaxy {
|
||||
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++ ) {
|
||||
PlaceBlock(p, lvl, x1, y, z1, brush);
|
||||
PlaceBlock(p, lvl, x2, y, z1, brush);
|
||||
PlaceBlock(p, lvl, x1, y, z2, brush);
|
||||
PlaceBlock(p, lvl, x2, y, z2, brush);
|
||||
PlaceBlock(p, lvl, x1, y, z1, brush.NextBlock());
|
||||
PlaceBlock(p, lvl, x2, y, z1, brush.NextBlock());
|
||||
PlaceBlock(p, lvl, x1, y, z2, brush.NextBlock());
|
||||
PlaceBlock(p, lvl, x2, y, z2, brush.NextBlock());
|
||||
}
|
||||
|
||||
for (ushort z = z1; z <= z2; z++) {
|
||||
PlaceBlock(p, lvl, x1, y1, z, brush);
|
||||
PlaceBlock(p, lvl, x2, y1, z, brush);
|
||||
PlaceBlock(p, lvl, x1, y2, z, brush);
|
||||
PlaceBlock(p, lvl, x2, y2, z, brush);
|
||||
PlaceBlock(p, lvl, x1, y1, z, brush.NextBlock());
|
||||
PlaceBlock(p, lvl, x2, y1, z, brush.NextBlock());
|
||||
PlaceBlock(p, lvl, x1, y2, z, brush.NextBlock());
|
||||
PlaceBlock(p, lvl, x2, y2, z, brush.NextBlock());
|
||||
}
|
||||
|
||||
for (ushort x = x1; x <= x2; x++) {
|
||||
PlaceBlock(p, lvl, x, y1, z1, brush);
|
||||
PlaceBlock(p, lvl, x, y1, z2, brush);
|
||||
PlaceBlock(p, lvl, x, y2, z1, brush);
|
||||
PlaceBlock(p, lvl, x, y2, z2, brush);
|
||||
PlaceBlock(p, lvl, x, y1, z1, brush.NextBlock());
|
||||
PlaceBlock(p, lvl, x, y1, z2, brush.NextBlock());
|
||||
PlaceBlock(p, lvl, x, y2, z1, brush.NextBlock());
|
||||
PlaceBlock(p, lvl, x, y2, z2, brush.NextBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,8 +61,7 @@ namespace MCGalaxy {
|
||||
TotalModified = 0;
|
||||
}
|
||||
|
||||
protected void PlaceBlock(Player p, Level lvl, ushort x, ushort y, ushort z, Brush brush) {
|
||||
byte type = brush.NextBlock();
|
||||
protected void PlaceBlock(Player p, Level lvl, ushort x, ushort y, ushort z, byte type) {
|
||||
if (type == Block.Zero)
|
||||
return;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user