public void SetBlock(int x, int y, int z, BlockType bType) { if (((x >= this.X) || (x < 0)) || ((y >= this.Y) || (y < 0)) || ((z >= this.Z) || (z < 0))) { throw new ArgumentException("GetBlockType: x=" + x + " y=" + y + " z=" + z); } else { data[x, y, z] = Block.New(bType); } }
private void place(BlockVector v, bool rotate) { if (currentSim[v].ID == selectedBlock) { Block b = currentSim[v]; Direction old = b.Place; switch (selectedBlock) { case BlockType.TORCH: case BlockType.LEVER: if (b.Place == Direction.WEST) { b.Place = Direction.DOWN; } else { b.Place++; } if (currentSim[v.South].isBlock && b.Place == Direction.NORTH) { break; } if (currentSim[v.East].isBlock && b.Place == Direction.WEST) { break; } if (currentSim[v.North].isBlock && b.Place == Direction.SOUTH) { break; } if (currentSim[v.West].isBlock && b.Place == Direction.EAST) { break; } if (currentSim[v.Down].isBlock && b.Place == Direction.DOWN) { break; } if (b.Place != old) { goto case BlockType.LEVER; } b.Place = old; break; case BlockType.BUTTON: if (b.Place == Direction.WEST) { b.Place = Direction.DOWN; } else { b.Place++; } if (currentSim[v.South].isBlock && b.Place == Direction.NORTH) { break; } if (currentSim[v.East].isBlock && b.Place == Direction.WEST) { break; } if (currentSim[v.North].isBlock && b.Place == Direction.SOUTH) { break; } if (currentSim[v.West].isBlock && b.Place == Direction.EAST) { break; } if (b.Place != old) { goto case BlockType.LEVER; } b.Place = old; break; case BlockType.REPEATER: if (b.Place == Direction.WEST) { b.Place = Direction.NORTH; } else { b.Place++; } break; } } else { Block oldBlock = currentSim[v]; Block b = Block.New(selectedBlock); Direction old = b.Place; switch (selectedBlock) { case BlockType.TORCH: case BlockType.LEVER: if (b.Place == Direction.WEST) { b.Place = Direction.DOWN; } else { b.Place++; } if (currentSim[v.South].isBlock && b.Place == Direction.NORTH) { currentSim[v] = b; break; } if (currentSim[v.East].isBlock && b.Place == Direction.WEST) { currentSim[v] = b; break; } if (currentSim[v.North].isBlock && b.Place == Direction.SOUTH) { currentSim[v] = b; break; } if (currentSim[v.West].isBlock && b.Place == Direction.EAST) { currentSim[v] = b; break; } if (currentSim[v.Down].isBlock && b.Place == Direction.DOWN) { currentSim[v] = b; break; } if (b.Place != old) { goto case BlockType.LEVER; } return; case BlockType.BUTTON: if (b.Place == Direction.WEST) { b.Place = Direction.DOWN; } else { b.Place++; } if (currentSim[v.South].isBlock && b.Place == Direction.NORTH) { currentSim[v] = b; break; } if (currentSim[v.East].isBlock && b.Place == Direction.WEST) { currentSim[v] = b; break; } if (currentSim[v.North].isBlock && b.Place == Direction.SOUTH) { currentSim[v] = b; break; } if (currentSim[v.West].isBlock && b.Place == Direction.EAST) { currentSim[v] = b; break; } if (b.Place != old) { goto case BlockType.LEVER; } return; case BlockType.REPEATER: if (b.Place == Direction.WEST) { b.Place = Direction.NORTH; } else { b.Place++; } currentSim[v] = b; break; case BlockType.WIRE: currentSim[v] = b; currentSim.setConnections(v); break; default: currentSim[v] = b; //if the old block was a wire, we need to recheck the connections //so that the previously wired block does not hold the wire connections //that it did previously hold // Was: | Now Is: // ┌┐ -> ┌┐ | ┌┐ -> ┌─ // └┘ -> └ | └┘ -> │ // if (oldBlock.ID == BlockType.WIRE) { currentSim.setConnections(v); } break; } } currentSim.updateT(); this.Refresh(); }