From 49adf1fae72b0d7aa166c9558e6fdbc82becdb13 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 2 Nov 2019 10:45:23 -0400 Subject: [PATCH] Fixed to mobile input --- .../io/anuke/mindustry/input/InputHandler.java | 15 +++++++-------- .../src/io/anuke/mindustry/input/MobileInput.java | 13 +++++++++---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/core/src/io/anuke/mindustry/input/InputHandler.java b/core/src/io/anuke/mindustry/input/InputHandler.java index 0e84cff407..672e1e1352 100644 --- a/core/src/io/anuke/mindustry/input/InputHandler.java +++ b/core/src/io/anuke/mindustry/input/InputHandler.java @@ -392,13 +392,12 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } } - /* for(BuildRequest req : selectRequests){ if(req.breaking) continue; if(req.bounds(Tmp.r2).overlaps(Tmp.r1)){ drawBreaking(req); } - }*/ + } for(BrokenBlock req : state.teams.get(player.getTeam()).brokenBlocks){ Block block = content.block(req.block); @@ -429,12 +428,13 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ protected void flushSelectRequests(Array requests){ for(BuildRequest req : requests){ if(req.block != null && validPlace(req.x, req.y, req.block, req.rotation)){ - BuildRequest other = getRequest(req.x, req.y); - if(other != null){ + BuildRequest other = getRequest(req.x, req.y, req.block.size, null); + if(other == null){ + selectRequests.add(req.copy()); + }else if(!other.breaking && other.x == req.x && other.y == req.y && other.block.size == req.block.size){ selectRequests.remove(other); + selectRequests.add(req.copy()); } - - selectRequests.add(req.copy()); } } } @@ -498,14 +498,13 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } } - /* it = selectRequests.iterator(); while(it.hasNext()){ BuildRequest req = it.next(); if(!req.breaking && req.bounds(Tmp.r2).overlaps(Tmp.r1)){ it.remove(); } - }*/ + } //remove blocks to rebuild Iterator broken = state.teams.get(player.getTeam()).brokenBlocks.iterator(); diff --git a/core/src/io/anuke/mindustry/input/MobileInput.java b/core/src/io/anuke/mindustry/input/MobileInput.java index 36f068a93d..0e3f471761 100644 --- a/core/src/io/anuke/mindustry/input/MobileInput.java +++ b/core/src/io/anuke/mindustry/input/MobileInput.java @@ -218,11 +218,13 @@ public class MobileInput extends InputHandler implements GestureListener{ if(tile != null){ if(!request.breaking){ if(validPlace(request.x, request.y, request.block, request.rotation)){ - BuildRequest other = getRequest(request.x, request.y); - if(other != null){ + BuildRequest other = getRequest(request.x, request.y, request.block.size, null); + if(other == null){ + player.addBuildRequest(request.copy()); + }else if(!other.breaking && other.x == request.x && other.y == request.y && other.block.size == request.block.size){ player.buildQueue().remove(other); + player.addBuildRequest(request.copy()); } - player.addBuildRequest(request.copy()); } rotation = request.rotation; @@ -359,7 +361,10 @@ public class MobileInput extends InputHandler implements GestureListener{ if(i == lineRequests.size - 1 && req.block.rotate){ drawArrow(block, req.x, req.y, req.rotation); } - drawRequest(lineRequests.get(i)); + + BuildRequest request = lineRequests.get(i); + request.block.drawRequest(request, allRequests(), validPlace(request.x, request.y, request.block, request.rotation) && getRequest(req.x, request.y, request.block.size, null) == null); + drawSelected(request.x, request.y, request.block, Pal.accent); } }else if(mode == breaking){ drawBreakSelection(lineStartX, lineStartY, tileX, tileY);