Fixed shaky camera, many other small bugs

This commit is contained in:
Anuken
2018-05-30 23:51:42 -04:00
parent fae7bfa8c5
commit 857b76980b
12 changed files with 81 additions and 36 deletions

View File

@@ -19,8 +19,6 @@ import io.anuke.mindustry.input.PlaceUtils.NormalizeResult;
import io.anuke.mindustry.type.Recipe;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.BuildBlock;
import io.anuke.mindustry.world.blocks.types.BuildBlock.BuildEntity;
import io.anuke.ucore.core.Core;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Graphics;
@@ -267,14 +265,9 @@ public class AndroidInput extends InputHandler implements GestureListener{
//only begin selecting if the tapped block is a request
selecting = hasRequest(cursor) && isPlacing();
Tile linked = cursor.target();
//when tapping a build block, select it
if(linked.block() instanceof BuildBlock){
BuildEntity entity = linked.entity();
player.replaceBuilding(linked.x, linked.y, linked.getRotation(), entity.recipe);
}else if(pointer == 0 && !selecting){
tileTapped(cursor);
//call tap events
if(pointer == 0 && !selecting){
tileTapped(cursor.target());
}
return false;

View File

@@ -145,7 +145,7 @@ public class DesktopInput extends InputHandler{
Tile cursor = tileAt(control.gdxInput().getX(), control.gdxInput().getY());
if(cursor != null && cursor.block().isConfigurable(cursor)){
if(cursor != null && cursor.target().block().isCursor(cursor.target())){
handCursor = true;
}
@@ -165,7 +165,6 @@ public class DesktopInput extends InputHandler{
if(player.isDead() || state.is(State.menu) || ui.hasDialog()) return false;
Tile cursor = tileAt(screenX, screenY);
if(cursor == null) return false;
if(button == Buttons.LEFT) { //left = begin placing
@@ -174,7 +173,10 @@ public class DesktopInput extends InputHandler{
selectY = cursor.y;
mode = placing;
} else {
tileTapped(cursor);
//only begin shooting if there's no cursor event
if(!tileTapped(cursor) && player.getPlaceQueue().size == 0){
shooting = true;
}
}
}else if(button == Buttons.RIGHT){ //right = begin breaking
selectX = cursor.x;
@@ -190,6 +192,10 @@ public class DesktopInput extends InputHandler{
@Override
public boolean touchUp (int screenX, int screenY, int pointer, int button) {
if(button == Buttons.LEFT){
shooting = false;
}
if(player.isDead() || state.is(State.menu) || ui.hasDialog()) return false;
Tile cursor = tileAt(screenX, screenY);
@@ -199,7 +205,6 @@ public class DesktopInput extends InputHandler{
return false;
}
if(mode == placing){ //touch up while placing, place everything in selection
NormalizeResult result = PlaceUtils.normalizeArea(selectX, selectY, cursor.x, cursor.y, rotation, true, maxLength);

View File

@@ -82,10 +82,14 @@ public abstract class InputHandler extends InputAdapter{
}
/**Handles tile tap events that are not platform specific.*/
public void tileTapped(Tile tile){
public boolean tileTapped(Tile tile){
tile = tile.target();
boolean consumed = false;
//check if tapped block is configurable
if(tile.block().isConfigurable(tile)){
consumed = true;
if((!frag.config.isShown() //if the config fragment is hidden, show
//alternatively, the current selected block can 'agree' to switch config tiles
|| frag.config.getSelectedTile().block().onConfigureTileTapped(frag.config.getSelectedTile(), tile))) {
@@ -95,13 +99,18 @@ public abstract class InputHandler extends InputAdapter{
}else if(!frag.config.hasConfigMouse()){ //make sure a configuration fragment isn't on the cursor
//then, if it's shown and the current block 'agrees' to hide, hide it.
if(frag.config.isShown() && frag.config.getSelectedTile().block().onConfigureTileTapped(frag.config.getSelectedTile(), tile)) {
consumed = true;
frag.config.hideConfig();
}
}
//TODO network event!
//call tapped event
tile.block().tapped(tile, player);
if(tile.block().tapped(tile, player)){
consumed = true;
}
return consumed;
}
//utility methods