Added allowRectanglePlacement for 1x1 blocks

This commit is contained in:
Anuken
2024-01-22 16:41:43 -05:00
parent 066fa04ded
commit bd4ae0639d
7 changed files with 40 additions and 6 deletions

View File

@@ -58,6 +58,22 @@ public class Placement{
return points;
}
/** Normalize two points into a rectangle. */
public static Seq<Point2> normalizeRectangle(int startX, int startY, int endX, int endY, int blockSize){
Pools.freeAll(points);
points.clear();
int minX = Math.min(startX, endX), minY = Math.min(startY, endY), maxX = Math.max(startX, endX), maxY = Math.max(startY, endY);
for(int y = minY; y <= maxY; y += blockSize){
for(int x = minX; x <= maxX; x += blockSize){
points.add(Pools.obtain(Point2.class, Point2::new).set(x, y));
}
}
return points;
}
public static Seq<Point2> upgradeLine(int startX, int startY, int endX, int endY){
closed.clear();
Pools.freeAll(points);