Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions src/autodrill/filler/WallDrill.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ public static void fill(Tile tile, BeamDrill drill, Direction direction) {
Seq<Integer> occupiedSecondaryAxis = new Seq<>();

Direction directionOpposite = Direction.getOpposite(direction);
Point2 offset = getDirectionOffset(direction, drill);
Point2 offsetOpposite = getDirectionOffset(directionOpposite, drill);
// Use separate offset functions to avoid circular dependency between opposite directions
Point2 offset = getDirectionOffsetForDrill(direction, drill);
Point2 offsetOpposite = getDirectionOffsetForDuct(directionOpposite, drill);
for (Tile tile1 : tiles) {
for (int i = 0; i < drill.range; i++) {
Tile boreTile = tile1.nearby((i + 1) * -direction.p.x + offset.x, (i + 1) * -direction.p.y + offset.y);
Expand Down Expand Up @@ -176,7 +177,10 @@ private static Seq<Tile> getConnectedWallTiles(Tile tile, Direction direction) {

Item sourceItem = tile.wallDrop();

int maxTiles = (int) (Core.settings.getInt(bundle.get("auto-drill.settings.max-tiles")) * 0.25f);
// Use mechanical drill settings as base, with 0.25x multiplier for wall tiles
// Default to 200 if setting not found
int baseSetting = Core.settings.getInt("mechanical-drill-max-tiles", 200);
int maxTiles = (int) (baseSetting * 0.25f);

while (!queue.isEmpty() && tiles.size < maxTiles) {
Tile currentTile = queue.removeFirst();
Expand Down Expand Up @@ -220,7 +224,31 @@ private static Seq<Tile> getConnectedWallTiles(Tile tile, Direction direction) {
return tiles;
}

private static Point2 getDirectionOffset(Direction direction, Block block) {
// Calculate offset for drill placement
// Separate from duct offset to avoid circular dependency between opposite directions
private static Point2 getDirectionOffsetForDrill(Direction direction, Block block) {
int offset1 = (block.size - 1) / 2;
int offset2 = block.size / 2;

switch (direction) {
case RIGHT -> {
return new Point2(-offset2, 0);
}
case UP -> {
return new Point2(0, -offset2);
}
case LEFT -> {
return new Point2(-offset2, -1);
}
default -> { // DOWN
return new Point2(-offset2, 0);
}
}
}

// Calculate offset for duct placement
// Independent from drill offset to prevent placement conflicts
private static Point2 getDirectionOffsetForDuct(Direction direction, Block block) {
int offset1 = (block.size - 1) / 2;
int offset2 = block.size / 2;

Expand All @@ -234,8 +262,8 @@ private static Point2 getDirectionOffset(Direction direction, Block block) {
case LEFT -> {
return new Point2(offset1, 0);
}
default -> {
return new Point2(0, offset1);
default -> { // DOWN
return new Point2(offset1, 0);
}
}
}
Expand Down