it launches
This commit is contained in:
@@ -44,12 +44,12 @@ public class DesktopInput extends InputHandler{
|
||||
@Override
|
||||
public void buildUI(Group group){
|
||||
group.fill(t -> {
|
||||
t.bottom().update(() -> t.getColor().a = Mathf.lerpDelta(t.getColor().a, player.isBuilding() ? 1f : 0f, 0.15f));
|
||||
t.bottom().update(() -> t.getColor().a = Mathf.lerpDelta(t.getColor().a, player.builder().isBuilding() ? 1f : 0f, 0.15f));
|
||||
t.visible(() -> Core.settings.getBool("hints") && selectRequests.isEmpty());
|
||||
t.touchable(() -> t.getColor().a < 0.1f ? Touchable.disabled : Touchable.childrenOnly);
|
||||
t.table(Styles.black6, b -> {
|
||||
b.defaults().left();
|
||||
b.label(() -> Core.bundle.format(!player.isBuilding ? "resumebuilding" : "pausebuilding", Core.keybinds.get(Binding.pause_building).key.toString())).style(Styles.outlineLabel);
|
||||
b.label(() -> Core.bundle.format(!isBuilding ? "resumebuilding" : "pausebuilding", Core.keybinds.get(Binding.pause_building).key.toString())).style(Styles.outlineLabel);
|
||||
b.row();
|
||||
b.label(() -> Core.bundle.format("cancelbuilding", Core.keybinds.get(Binding.clear_building).key.toString())).style(Styles.outlineLabel);
|
||||
b.row();
|
||||
@@ -150,7 +150,7 @@ public class DesktopInput extends InputHandler{
|
||||
}
|
||||
|
||||
if(Core.input.keyRelease(Binding.select)){
|
||||
player.isShooting = false;
|
||||
isShooting = false;
|
||||
}
|
||||
|
||||
if(!state.is(State.menu) && Core.input.keyTap(Binding.minimap) && !scene.hasDialog() && !(scene.getKeyboardFocus() instanceof TextField)){
|
||||
@@ -176,8 +176,8 @@ public class DesktopInput extends InputHandler{
|
||||
mode = none;
|
||||
}
|
||||
|
||||
if(player.isShooting && !canShoot()){
|
||||
player.isShooting = false;
|
||||
if(isShooting && !canShoot()){
|
||||
isShooting = false;
|
||||
}
|
||||
|
||||
if(isPlacing()){
|
||||
@@ -272,9 +272,9 @@ public class DesktopInput extends InputHandler{
|
||||
int rawCursorX = world.toTile(Core.input.mouseWorld().x), rawCursorY = world.toTile(Core.input.mouseWorld().y);
|
||||
|
||||
// automatically pause building if the current build queue is empty
|
||||
if(Core.settings.getBool("buildautopause") && player.isBuilding && !player.isBuilding()){
|
||||
player.isBuilding = false;
|
||||
player.buildWasAutoPaused = true;
|
||||
if(Core.settings.getBool("buildautopause") && isBuilding && !player.builder().isBuilding()){
|
||||
isBuilding = false;
|
||||
buildWasAutoPaused = true;
|
||||
}
|
||||
|
||||
if(!selectRequests.isEmpty()){
|
||||
@@ -290,11 +290,11 @@ public class DesktopInput extends InputHandler{
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.deselect)){
|
||||
player.setMineTile(null);
|
||||
player.miner().mineTile(null);
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.clear_building)){
|
||||
player.clearBuilding();
|
||||
player.builder().clearBuilding();
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.schematic_select) && !Core.scene.hasKeyboard()){
|
||||
@@ -346,8 +346,8 @@ public class DesktopInput extends InputHandler{
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.pause_building)){
|
||||
player.isBuilding = !player.isBuilding;
|
||||
player.buildWasAutoPaused = false;
|
||||
isBuilding = !isBuilding;
|
||||
buildWasAutoPaused = false;
|
||||
}
|
||||
|
||||
if((cursorX != lastLineX || cursorY != lastLineY) && isPlacing() && mode == placing){
|
||||
@@ -376,12 +376,12 @@ public class DesktopInput extends InputHandler{
|
||||
deleting = true;
|
||||
}else if(selected != null){
|
||||
//only begin shooting if there's no cursor event
|
||||
if(!tileTapped(selected) && !tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && (player.builder().requests().size == 0 || !player.isBuilding) && !droppingItem &&
|
||||
!tryBeginMine(selected) && player.getMineTile() == null && !Core.scene.hasKeyboard()){
|
||||
player.isShooting = true;
|
||||
if(!tileTapped(selected) && !tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && (player.builder().requests().size == 0 || !player.builder().isBuilding()) && !droppingItem &&
|
||||
!tryBeginMine(selected) && player.miner().mineTile() == null && !Core.scene.hasKeyboard()){
|
||||
isShooting = true;
|
||||
}
|
||||
}else if(!Core.scene.hasKeyboard()){ //if it's out of bounds, shooting is just fine
|
||||
player.isShooting = true;
|
||||
isShooting = true;
|
||||
}
|
||||
}else if(Core.input.keyTap(Binding.deselect) && isPlacing()){
|
||||
block = null;
|
||||
|
||||
@@ -17,7 +17,6 @@ import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
@@ -25,8 +24,8 @@ import mindustry.game.Teams.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.input.Placement.*;
|
||||
import mindustry.net.*;
|
||||
import mindustry.net.Administration.*;
|
||||
import mindustry.net.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.fragments.*;
|
||||
import mindustry.world.*;
|
||||
@@ -55,6 +54,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
public int rotation;
|
||||
public boolean droppingItem;
|
||||
public Group uiGroup;
|
||||
public boolean isShooting, isBuilding = true, buildWasAutoPaused = false;
|
||||
|
||||
protected @Nullable Schematic lastSchematic;
|
||||
protected GestureDetector detector;
|
||||
@@ -627,14 +627,14 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
boolean canTapPlayer(float x, float y){
|
||||
return Mathf.dst(x, y, player.x, player.y) <= playerSelectRange && player.unit().stack().amount > 0;
|
||||
return player.within(x, y, playerSelectRange) && player.unit().stack().amount > 0;
|
||||
}
|
||||
|
||||
/** Tries to begin mining a tile, returns true if successful. */
|
||||
boolean tryBeginMine(Tile tile){
|
||||
if(canMine(tile)){
|
||||
//if a block is clicked twice, reset it
|
||||
player.setMineTile(player.getMineTile() == tile ? null : tile);
|
||||
player.miner().mineTile(player.miner().mineTile() == tile ? null : tile);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -642,10 +642,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
|
||||
boolean canMine(Tile tile){
|
||||
return !Core.scene.hasMouse()
|
||||
&& tile.drop() != null && tile.drop().hardness <= player.mech.drillPower
|
||||
&& tile.drop() != null && player.miner().canMine(tile.drop())
|
||||
&& !(tile.floor().playerUnmineable && tile.overlay().itemDrop == null)
|
||||
&& player.unit().acceptsItem(tile.drop())
|
||||
&& tile.block() == Blocks.air && player.dst(tile.worldx(), tile.worldy()) <= Playerc.mineDistance;
|
||||
&& tile.block() == Blocks.air && player.dst(tile.worldx(), tile.worldy()) <= miningRange;
|
||||
}
|
||||
|
||||
/** Returns the tile at the specified MOUSE coordinates. */
|
||||
@@ -1050,7 +1050,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
//update shooting if not building, not mining and there's ammo left
|
||||
if(!isBuilding() && getMineTile() == null){
|
||||
if(!isBuilding() && mineTile() == null){
|
||||
|
||||
//autofire
|
||||
if(target == null){
|
||||
@@ -1068,7 +1068,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
if(target != null){
|
||||
setMineTile(null);
|
||||
mineTile(null);
|
||||
}
|
||||
}
|
||||
}else if(target.isValid() || (target instanceof Tilec && ((Tilec)target).damaged() && target.team() == team && mech.canHeal && dst(target) < mech.range)){
|
||||
|
||||
@@ -63,6 +63,8 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
/** Down tracking for panning.*/
|
||||
private boolean down = false;
|
||||
|
||||
private Teamc target;
|
||||
|
||||
//region utility methods
|
||||
|
||||
/** Check and assign targets for a specific position. */
|
||||
@@ -70,19 +72,20 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
Unitc unit = Units.closestEnemy(player.team(), x, y, 20f, u -> !u.dead());
|
||||
|
||||
if(unit != null){
|
||||
player.setMineTile(null);
|
||||
player.target = unit;
|
||||
player.miner().mineTile(null);
|
||||
target = unit;
|
||||
}else{
|
||||
Tile tile = world.ltileWorld(x, y);
|
||||
|
||||
if(tile != null && tile.synthetic() && player.team().isEnemy(tile.team())){
|
||||
Tilec entity = tile.entity;
|
||||
player.setMineTile(null);
|
||||
player.target = entity;
|
||||
}else if(tile != null && player.mech.canHeal && tile.entity != null && tile.team() == player.team() && tile.entity.damaged()){
|
||||
player.setMineTile(null);
|
||||
player.target = tile.entity;
|
||||
}
|
||||
player.miner().mineTile(null);
|
||||
target = entity;
|
||||
//TODO implement healing
|
||||
}//else if(tile != null && player.unit().canHeal && tile.entity != null && tile.team() == player.team() && tile.entity.damaged()){
|
||||
/// player.miner().mineTile(null);
|
||||
// target = tile.entity;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,9 +253,9 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
Boolp schem = () -> lastSchematic != null && !selectRequests.isEmpty();
|
||||
|
||||
group.fill(t -> {
|
||||
t.bottom().left().visible(() -> (player.isBuilding() || block != null || mode == breaking || !selectRequests.isEmpty()) && !schem.get());
|
||||
t.bottom().left().visible(() -> (player.builder().isBuilding() || block != null || mode == breaking || !selectRequests.isEmpty()) && !schem.get());
|
||||
t.addImageTextButton("$cancel", Icon.cancel, () -> {
|
||||
player.clearBuilding();
|
||||
player.builder().clearBuilding();
|
||||
selectRequests.clear();
|
||||
mode = none;
|
||||
block = null;
|
||||
@@ -375,8 +378,6 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
}
|
||||
}
|
||||
|
||||
Teamc target = player.target;
|
||||
|
||||
//draw targeting crosshair
|
||||
if(target != null && !state.isEditor()){
|
||||
if(target != lastTarget){
|
||||
@@ -431,7 +432,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
@Override
|
||||
public void useSchematic(Schematic schem){
|
||||
selectRequests.clear();
|
||||
selectRequests.addAll(schematics.toRequests(schem, world.toTile(player.x), world.toTile(player.y)));
|
||||
selectRequests.addAll(schematics.toRequests(schem, player.tileX(), player.tileY()));
|
||||
lastSchematic = schem;
|
||||
}
|
||||
|
||||
@@ -467,7 +468,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
lastLineY = tileY;
|
||||
}else if(!tryTapPlayer(worldx, worldy) && Core.settings.getBool("keyboard")){
|
||||
//shoot on touch down when in keyboard mode
|
||||
player.isShooting = true;
|
||||
isShooting = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -602,11 +603,11 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
|
||||
if(Core.settings.getBool("keyboard")){
|
||||
if(Core.input.keyRelease(Binding.select)){
|
||||
player.isShooting = false;
|
||||
isShooting = false;
|
||||
}
|
||||
|
||||
if(player.isShooting && !canShoot()){
|
||||
player.isShooting = false;
|
||||
if(isShooting && !canShoot()){
|
||||
isShooting = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user