Fixed breaking with multiblock being offseted
This commit is contained in:
@@ -151,14 +151,6 @@ public class DesktopInput extends InputHandler{
|
|||||||
|
|
||||||
pollInput();
|
pollInput();
|
||||||
|
|
||||||
//removed for now, will add back if necessary
|
|
||||||
/*
|
|
||||||
if(recipe != null && !Settings.getBool("desktop-place-help-2", false)){
|
|
||||||
ui.showInfo("$text.construction.desktop");
|
|
||||||
Settings.putBool("desktop-place-help-2", true);
|
|
||||||
Settings.save();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//deselect if not placing
|
//deselect if not placing
|
||||||
if(!isPlacing() && mode == placing){
|
if(!isPlacing() && mode == placing){
|
||||||
mode = none;
|
mode = none;
|
||||||
@@ -238,9 +230,10 @@ public class DesktopInput extends InputHandler{
|
|||||||
recipe = null;
|
recipe = null;
|
||||||
mode = none;
|
mode = none;
|
||||||
}else if(Inputs.keyTap(section, "break") && !ui.hasMouse()){
|
}else if(Inputs.keyTap(section, "break") && !ui.hasMouse()){
|
||||||
selectX = cursorX;
|
//is recalculated because setting the mode to breaking removes potential multiblock cursor offset
|
||||||
selectY = cursorY;
|
|
||||||
mode = breaking;
|
mode = breaking;
|
||||||
|
selectX = tileX(Gdx.input.getX());
|
||||||
|
selectY = tileY(Gdx.input.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -278,6 +271,11 @@ public class DesktopInput extends InputHandler{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean selectedBlock(){
|
||||||
|
return isPlacing() && mode != breaking;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getMouseX(){
|
public float getMouseX(){
|
||||||
return !controlling ? Gdx.input.getX() : controlx;
|
return !controlling ? Gdx.input.getX() : controlx;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import io.anuke.annotations.Annotations.Remote;
|
|||||||
import io.anuke.mindustry.content.blocks.Blocks;
|
import io.anuke.mindustry.content.blocks.Blocks;
|
||||||
import io.anuke.mindustry.content.fx.EnvironmentFx;
|
import io.anuke.mindustry.content.fx.EnvironmentFx;
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.entities.Units;
|
|
||||||
import io.anuke.mindustry.entities.effect.ItemTransfer;
|
import io.anuke.mindustry.entities.effect.ItemTransfer;
|
||||||
import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest;
|
import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest;
|
||||||
import io.anuke.mindustry.gen.Call;
|
import io.anuke.mindustry.gen.Call;
|
||||||
@@ -277,7 +276,7 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
|
|
||||||
int tileX(float cursorX){
|
int tileX(float cursorX){
|
||||||
Vector2 vec = Graphics.world(cursorX, 0);
|
Vector2 vec = Graphics.world(cursorX, 0);
|
||||||
if(isPlacing()){
|
if(selectedBlock()){
|
||||||
vec.sub(recipe.result.offset(), recipe.result.offset());
|
vec.sub(recipe.result.offset(), recipe.result.offset());
|
||||||
}
|
}
|
||||||
return world.toTile(vec.x);
|
return world.toTile(vec.x);
|
||||||
@@ -285,12 +284,16 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
|
|
||||||
int tileY(float cursorY){
|
int tileY(float cursorY){
|
||||||
Vector2 vec = Graphics.world(0, cursorY);
|
Vector2 vec = Graphics.world(0, cursorY);
|
||||||
if(isPlacing()){
|
if(selectedBlock()){
|
||||||
vec.sub(recipe.result.offset(), recipe.result.offset());
|
vec.sub(recipe.result.offset(), recipe.result.offset());
|
||||||
}
|
}
|
||||||
return world.toTile(vec.y);
|
return world.toTile(vec.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean selectedBlock(){
|
||||||
|
return isPlacing();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isPlacing(){
|
public boolean isPlacing(){
|
||||||
return recipe != null;
|
return recipe != null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user