mirror of
https://github.com/demodude4u/Factorio-FBSR.git
synced 2024-11-24 08:12:21 +02:00
Selection boxes are now rotated to correct alignment calculation
This commit is contained in:
parent
a8aab64afc
commit
8c040d1a7c
@ -1,5 +1,6 @@
|
||||
package com.demod.fbsr;
|
||||
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Point2D.Double;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
@ -86,4 +87,10 @@ public enum Direction {
|
||||
Direction[] values = values();
|
||||
return values[(((ordinal() + deltaIndex) % values.length) + values.length) % values.length];
|
||||
}
|
||||
|
||||
public Rectangle2D rotateBounds(Rectangle2D bounds) {
|
||||
AffineTransform at = new AffineTransform();
|
||||
at.rotate(Math.PI * 2.0 * ordinal() / 8.0);
|
||||
return at.createTransformedShape(bounds).getBounds2D();
|
||||
}
|
||||
}
|
@ -93,14 +93,14 @@ public class FBSR {
|
||||
}
|
||||
|
||||
Point2D.Double position = tuple.entity.getPosition();
|
||||
Rectangle2D.Double selectionBox;
|
||||
Rectangle2D selectionBox;
|
||||
if (tuple.prototype != null) {
|
||||
selectionBox = tuple.prototype.getSelectionBox();
|
||||
selectionBox = tuple.entity.getDirection().rotateBounds(tuple.prototype.getSelectionBox());
|
||||
} else {
|
||||
selectionBox = new Rectangle2D.Double();
|
||||
}
|
||||
Rectangle2D.Double bounds = new Rectangle2D.Double(selectionBox.x + position.x, selectionBox.y + position.y,
|
||||
selectionBox.width, selectionBox.height);
|
||||
Rectangle2D.Double bounds = new Rectangle2D.Double(selectionBox.getX() + position.x,
|
||||
selectionBox.getY() + position.y, selectionBox.getWidth(), selectionBox.getHeight());
|
||||
// System.out.println(bounds);
|
||||
|
||||
// Everything is doubled and rounded to the closest original 0.5
|
||||
|
Loading…
Reference in New Issue
Block a user