Better diagonal placement system for nodes
This commit is contained in:
@@ -1475,7 +1475,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
int endRotation = -1;
|
||||
var start = world.build(startX, startY);
|
||||
var end = world.build(endX, endY);
|
||||
if(diagonal){
|
||||
if(diagonal && (block == null || block.allowDiagonal)){
|
||||
if(block != null && start instanceof ChainedBuilding && end instanceof ChainedBuilding
|
||||
&& block.canReplace(end.block) && block.canReplace(start.block)){
|
||||
points = Placement.upgradeLine(startX, startY, endX, endY);
|
||||
@@ -1493,7 +1493,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
if(block != null){
|
||||
block.changePlacementPath(points, rotation);
|
||||
block.changePlacementPath(points, rotation, diagonal);
|
||||
}
|
||||
|
||||
float angle = Angles.angle(startX, startY, endX, endY);
|
||||
|
||||
@@ -201,6 +201,8 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
public boolean sync;
|
||||
/** Whether this block uses conveyor-type placement mode. */
|
||||
public boolean conveyorPlacement;
|
||||
/** If false, diagonal placement (ctrl) for this block is not allowed. */
|
||||
public boolean allowDiagonal = true;
|
||||
/** Whether to swap the diagonal placement modes. */
|
||||
public boolean swapDiagonalPlacement;
|
||||
/** Build queue priority in schematics. */
|
||||
@@ -610,6 +612,11 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Mutates the given list of points used during line placement. */
|
||||
public void changePlacementPath(Seq<Point2> points, int rotation, boolean diagonalOn){
|
||||
changePlacementPath(points, rotation);
|
||||
}
|
||||
|
||||
/** Mutates the given list of points used during line placement. */
|
||||
public void changePlacementPath(Seq<Point2> points, int rotation){
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ public class BeamNode extends PowerBlock{
|
||||
consumesPower = outputsPower = false;
|
||||
drawDisabled = false;
|
||||
envEnabled |= Env.space;
|
||||
allowDiagonal = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,8 +83,10 @@ public class BeamNode extends PowerBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changePlacementPath(Seq<Point2> points, int rotation){
|
||||
Placement.calculateNodes(points, this, rotation, (point, other) -> Math.max(Math.abs(point.x - other.x), Math.abs(point.y - other.y)) <= range);
|
||||
public void changePlacementPath(Seq<Point2> points, int rotation, boolean diagonal){
|
||||
if(!diagonal){
|
||||
Placement.calculateNodes(points, this, rotation, (point, other) -> Math.max(Math.abs(point.x - other.x), Math.abs(point.y - other.y)) <= range);
|
||||
}
|
||||
}
|
||||
|
||||
public class BeamNodeBuild extends Building{
|
||||
|
||||
Reference in New Issue
Block a user