Fixed mobile mining/targeting conflict

This commit is contained in:
Anuken
2018-10-24 14:03:48 -04:00
parent 8b8c74cf93
commit 35e5a669a0
2 changed files with 20 additions and 16 deletions
@@ -714,11 +714,13 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
//autofire: mobile only! //autofire: mobile only!
if(mobile){ if(mobile){
if(target == null){ if(target == null){
isShooting = false; isShooting = false;
if(Settings.getBool("autotarget")){ if(Settings.getBool("autotarget")){
target = Units.getClosestTarget(team, x, y, getWeapon().getAmmo().getRange()); target = Units.getClosestTarget(team, x, y, getWeapon().getAmmo().getRange());
if(target != null){
setMineTile(null);
}
} }
}else if(target.isValid()){ }else if(target.isValid()){
//rotate toward and shoot the target //rotate toward and shoot the target
@@ -86,14 +86,16 @@ public class MobileInput extends InputHandler implements GestureListener{
Unit unit = Units.getClosestEnemy(player.getTeam(), x, y, 20f, u -> !u.isDead()); Unit unit = Units.getClosestEnemy(player.getTeam(), x, y, 20f, u -> !u.isDead());
if(unit != null){ if(unit != null){
threads.run(() -> player.target = unit); player.setMineTile(null);
player.target = unit;
}else{ }else{
Tile tile = world.tileWorld(x, y); Tile tile = world.tileWorld(x, y);
if(tile != null) tile = tile.target(); if(tile != null) tile = tile.target();
if(tile != null && state.teams.areEnemies(player.getTeam(), tile.getTeam())){ if(tile != null && state.teams.areEnemies(player.getTeam(), tile.getTeam())){
TileEntity entity = tile.entity; TileEntity entity = tile.entity;
threads.run(() -> player.target = entity); player.setMineTile(null);
player.target = entity;
} }
} }
} }