Better diagonal placement system for nodes

This commit is contained in:
Anuken
2022-04-06 23:21:47 -04:00
parent 14558975cb
commit 5699ecc01c
4 changed files with 15 additions and 5 deletions

View File

@@ -617,7 +617,7 @@ sectors.rename = Rename Sector
sectors.enemybase = [scarlet]Enemy Base sectors.enemybase = [scarlet]Enemy Base
sectors.vulnerable = [scarlet]Vulnerable sectors.vulnerable = [scarlet]Vulnerable
sectors.underattack = [scarlet]Under attack! [accent]{0}% damaged sectors.underattack = [scarlet]Under attack! [accent]{0}% damaged
sectors.underattack.nodamage = [scarlet]Enemy Present sectors.underattack.nodamage = [scarlet]Uncaptured
sectors.survives = [accent]Survives {0} waves sectors.survives = [accent]Survives {0} waves
sectors.go = Go sectors.go = Go
sector.curcapture = Sector Captured sector.curcapture = Sector Captured

View File

@@ -1475,7 +1475,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
int endRotation = -1; int endRotation = -1;
var start = world.build(startX, startY); var start = world.build(startX, startY);
var end = world.build(endX, endY); var end = world.build(endX, endY);
if(diagonal){ if(diagonal && (block == null || block.allowDiagonal)){
if(block != null && start instanceof ChainedBuilding && end instanceof ChainedBuilding if(block != null && start instanceof ChainedBuilding && end instanceof ChainedBuilding
&& block.canReplace(end.block) && block.canReplace(start.block)){ && block.canReplace(end.block) && block.canReplace(start.block)){
points = Placement.upgradeLine(startX, startY, endX, endY); points = Placement.upgradeLine(startX, startY, endX, endY);
@@ -1493,7 +1493,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
} }
if(block != null){ if(block != null){
block.changePlacementPath(points, rotation); block.changePlacementPath(points, rotation, diagonal);
} }
float angle = Angles.angle(startX, startY, endX, endY); float angle = Angles.angle(startX, startY, endX, endY);

View File

@@ -201,6 +201,8 @@ public class Block extends UnlockableContent implements Senseable{
public boolean sync; public boolean sync;
/** Whether this block uses conveyor-type placement mode. */ /** Whether this block uses conveyor-type placement mode. */
public boolean conveyorPlacement; 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. */ /** Whether to swap the diagonal placement modes. */
public boolean swapDiagonalPlacement; public boolean swapDiagonalPlacement;
/** Build queue priority in schematics. */ /** Build queue priority in schematics. */
@@ -610,6 +612,11 @@ public class Block extends UnlockableContent implements Senseable{
return this; 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. */ /** Mutates the given list of points used during line placement. */
public void changePlacementPath(Seq<Point2> points, int rotation){ public void changePlacementPath(Seq<Point2> points, int rotation){

View File

@@ -34,6 +34,7 @@ public class BeamNode extends PowerBlock{
consumesPower = outputsPower = false; consumesPower = outputsPower = false;
drawDisabled = false; drawDisabled = false;
envEnabled |= Env.space; envEnabled |= Env.space;
allowDiagonal = false;
} }
@Override @Override
@@ -82,8 +83,10 @@ public class BeamNode extends PowerBlock{
} }
@Override @Override
public void changePlacementPath(Seq<Point2> points, int rotation){ public void changePlacementPath(Seq<Point2> points, int rotation, boolean diagonal){
Placement.calculateNodes(points, this, rotation, (point, other) -> Math.max(Math.abs(point.x - other.x), Math.abs(point.y - other.y)) <= range); 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{ public class BeamNodeBuild extends Building{