mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-19 12:18:03 -04:00
Fix cuboid holes.
This commit is contained in:
parent
a98c35fbef
commit
002e114a6d
@ -91,25 +91,21 @@ namespace MCGalaxy.Commands
|
|||||||
|
|
||||||
switch (cpos.solid) {
|
switch (cpos.solid) {
|
||||||
case SolidType.solid:
|
case SolidType.solid:
|
||||||
drawOp = new CuboidDrawOp();
|
drawOp = new CuboidDrawOp(); break;
|
||||||
brush = new SolidBrush(type); break;
|
|
||||||
case SolidType.hollow:
|
case SolidType.hollow:
|
||||||
drawOp = new CuboidHollowsDrawOp();
|
drawOp = new CuboidHollowsDrawOp(); break;
|
||||||
brush = new SolidBrush(type); break;
|
|
||||||
case SolidType.walls:
|
case SolidType.walls:
|
||||||
drawOp = new CuboidWallsDrawOp();
|
drawOp = new CuboidWallsDrawOp(); break;
|
||||||
brush = new SolidBrush(type); break;
|
|
||||||
case SolidType.holes:
|
case SolidType.holes:
|
||||||
drawOp = new CuboidDrawOp();
|
drawOp = new CuboidHolesDrawOp(); break;
|
||||||
brush = new HolesBrush(type); break;
|
|
||||||
case SolidType.wire:
|
case SolidType.wire:
|
||||||
drawOp = new CuboidWireframeDrawOp();
|
drawOp = new CuboidWireframeDrawOp(); break;
|
||||||
brush = new SolidBrush(type); break;
|
|
||||||
case SolidType.random:
|
case SolidType.random:
|
||||||
drawOp = new CuboidDrawOp();
|
drawOp = new CuboidDrawOp();
|
||||||
brush = new RandomBrush(type); break;
|
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 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 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);
|
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 {
|
public sealed class RainbowBrush : Brush {
|
||||||
readonly Random rnd;
|
readonly Random rnd;
|
||||||
|
|
||||||
|
@ -35,7 +35,34 @@ namespace MCGalaxy {
|
|||||||
for (ushort z = z1; z <= z2; z++)
|
for (ushort z = z1; z <= z2; z++)
|
||||||
for (ushort x = x1; x <= x2; x++)
|
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 y = y1; y <= y2; y++)
|
||||||
for (ushort z = z1; z <= z2; z++)
|
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 z = z1; z <= z2; z++)
|
||||||
for (ushort x = x1; x <= x2; x++)
|
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 y = y1; y <= y2; y++)
|
||||||
for (ushort x = x1; x <= x2; x++)
|
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,
|
public override void Perform(ushort x1, ushort y1, ushort z1, ushort x2,
|
||||||
ushort y2, ushort z2, Player p, Level lvl, Brush brush) {
|
ushort y2, ushort z2, Player p, Level lvl, Brush brush) {
|
||||||
for (ushort y = y1; y <= y2; y++ ) {
|
for (ushort y = y1; y <= y2; y++ ) {
|
||||||
PlaceBlock(p, lvl, x1, y, z1, brush);
|
PlaceBlock(p, lvl, x1, y, z1, brush.NextBlock());
|
||||||
PlaceBlock(p, lvl, x2, y, z1, brush);
|
PlaceBlock(p, lvl, x2, y, z1, brush.NextBlock());
|
||||||
PlaceBlock(p, lvl, x1, y, z2, brush);
|
PlaceBlock(p, lvl, x1, y, z2, brush.NextBlock());
|
||||||
PlaceBlock(p, lvl, x2, y, z2, brush);
|
PlaceBlock(p, lvl, x2, y, z2, brush.NextBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ushort z = z1; z <= z2; z++) {
|
for (ushort z = z1; z <= z2; z++) {
|
||||||
PlaceBlock(p, lvl, x1, y1, z, brush);
|
PlaceBlock(p, lvl, x1, y1, z, brush.NextBlock());
|
||||||
PlaceBlock(p, lvl, x2, y1, z, brush);
|
PlaceBlock(p, lvl, x2, y1, z, brush.NextBlock());
|
||||||
PlaceBlock(p, lvl, x1, y2, z, brush);
|
PlaceBlock(p, lvl, x1, y2, z, brush.NextBlock());
|
||||||
PlaceBlock(p, lvl, x2, y2, z, brush);
|
PlaceBlock(p, lvl, x2, y2, z, brush.NextBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ushort x = x1; x <= x2; x++) {
|
for (ushort x = x1; x <= x2; x++) {
|
||||||
PlaceBlock(p, lvl, x, y1, z1, brush);
|
PlaceBlock(p, lvl, x, y1, z1, brush.NextBlock());
|
||||||
PlaceBlock(p, lvl, x, y1, z2, brush);
|
PlaceBlock(p, lvl, x, y1, z2, brush.NextBlock());
|
||||||
PlaceBlock(p, lvl, x, y2, z1, brush);
|
PlaceBlock(p, lvl, x, y2, z1, brush.NextBlock());
|
||||||
PlaceBlock(p, lvl, x, y2, z2, brush);
|
PlaceBlock(p, lvl, x, y2, z2, brush.NextBlock());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,7 @@ namespace MCGalaxy {
|
|||||||
TotalModified = 0;
|
TotalModified = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void PlaceBlock(Player p, Level lvl, ushort x, ushort y, ushort z, Brush brush) {
|
protected void PlaceBlock(Player p, Level lvl, ushort x, ushort y, ushort z, byte type) {
|
||||||
byte type = brush.NextBlock();
|
|
||||||
if (type == Block.Zero)
|
if (type == Block.Zero)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user