Better bridge linking

This commit is contained in:
Anuken
2020-12-17 18:35:50 -05:00
parent 0cc3340bd6
commit 6815f3305f
8 changed files with 64 additions and 41 deletions

View File

@@ -168,7 +168,6 @@ public class DesktopInput extends InputHandler{
block.drawRequestConfig(brequest, allRequests());
brequest.config = null;
}
}
}

View File

@@ -743,6 +743,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
for(BuildPlan req : requests){
if(req.block != null && validPlace(req.x, req.y, req.block, req.rotation)){
BuildPlan copy = req.copy();
req.block.onNewPlan(copy);
player.unit().addBuild(copy);
}
}
@@ -1080,12 +1081,6 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
}
}
public void tryPlaceBlock(int x, int y){
if(block != null && validPlace(x, y, block, rotation)){
placeBlock(x, y, block, rotation);
}
}
public void tryBreakBlock(int x, int y){
if(validBreak(x, y)){
breakBlock(x, y);
@@ -1112,14 +1107,6 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
return Build.validBreak(player.team(), x, y);
}
public void placeBlock(int x, int y, Block block, int rotation){
BuildPlan req = getRequest(x, y);
if(req != null){
player.unit().plans().remove(req);
}
player.unit().addBuild(new BuildPlan(x, y, rotation, block, block.nextConfig()));
}
public void breakBlock(int x, int y){
Tile tile = world.tile(x, y);
if(tile != null && tile.build != null) tile = tile.build.tile;

View File

@@ -354,6 +354,9 @@ public class MobileInput extends InputHandler implements GestureListener{
Draw.reset();
drawRequest(request);
if(!request.breaking){
drawOverRequest(request);
}
//draw last placed request
if(!request.breaking && request == lastPlaced && request.block != null){
@@ -596,6 +599,7 @@ public class MobileInput extends InputHandler implements GestureListener{
}else if(mode == placing && isPlacing() && validPlace(cursor.x, cursor.y, block, rotation) && !checkOverlapPlacement(cursor.x, cursor.y, block)){
//add to selection queue if it's a valid place position
selectRequests.add(lastPlaced = new BuildPlan(cursor.x, cursor.y, rotation, block, block.nextConfig()));
block.onNewPlan(lastPlaced);
}else if(mode == breaking && validBreak(linked.x,linked.y) && !hasRequest(linked)){
//add to selection queue if it's a valid BREAK position
selectRequests.add(new BuildPlan(linked.x, linked.y));