Merged in better multithreading
This commit is contained in:
@@ -267,7 +267,6 @@ public abstract class InputHandler extends InputAdapter{
|
||||
&& tile.floor().drops != null && tile.floor().drops.item.hardness <= player.mech.drillPower
|
||||
&& !tile.floor().playerUnmineable
|
||||
&& player.inventory.canAcceptItem(tile.floor().drops.item)
|
||||
&& Units.getClosestEnemy(player.getTeam(), tile.worldx(), tile.worldy(), 40f, e -> true) == null //don't being mining when an enemy is near
|
||||
&& tile.block() == Blocks.air && player.distanceTo(tile.worldx(), tile.worldy()) <= Player.mineDistance;
|
||||
}
|
||||
|
||||
@@ -354,7 +353,7 @@ public abstract class InputHandler extends InputAdapter{
|
||||
for(Tile tile : state.teams.get(player.getTeam()).cores){
|
||||
if(tile.distanceTo(x * tilesize, y * tilesize) < coreBuildRange){
|
||||
return Build.validPlace(player.getTeam(), x, y, type, rotation) &&
|
||||
Vector2.dst(player.x, player.y, x * tilesize, y * tilesize) < Player.placeDistance;
|
||||
Vector2.dst(player.x, player.y, x * tilesize, y * tilesize) < Player.placeDistance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,12 +365,10 @@ public abstract class InputHandler extends InputAdapter{
|
||||
}
|
||||
|
||||
public void placeBlock(int x, int y, Recipe recipe, int rotation){
|
||||
//todo multiplayer support
|
||||
player.addBuildRequest(new BuildRequest(x, y, rotation, recipe));
|
||||
}
|
||||
|
||||
public void breakBlock(int x, int y){
|
||||
//todo multiplayer support
|
||||
Tile tile = world.tile(x, y).target();
|
||||
player.addBuildRequest(new BuildRequest(tile.x, tile.y));
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
@@ -84,19 +83,17 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
|
||||
/** Check and assign targets for a specific position. */
|
||||
void checkTargets(float x, float y){
|
||||
synchronized(Entities.entityLock){
|
||||
Unit unit = Units.getClosestEnemy(player.getTeam(), x, y, 20f, u -> !u.isDead() && u.isAdded());
|
||||
Unit unit = Units.getClosestEnemy(player.getTeam(), x, y, 20f, u -> !u.isDead());
|
||||
|
||||
if(unit != null){
|
||||
threads.run(() -> player.target = unit);
|
||||
}else{
|
||||
Tile tile = world.tileWorld(x, y);
|
||||
if(tile != null) tile = tile.target();
|
||||
if(unit != null){
|
||||
threads.run(() -> player.target = unit);
|
||||
}else{
|
||||
Tile tile = world.tileWorld(x, y);
|
||||
if(tile != null) tile = tile.target();
|
||||
|
||||
if(tile != null && state.teams.areEnemies(player.getTeam(), tile.getTeam())){
|
||||
TileEntity entity = tile.entity;
|
||||
threads.run(() -> player.target = entity);
|
||||
}
|
||||
if(tile != null && state.teams.areEnemies(player.getTeam(), tile.getTeam())){
|
||||
TileEntity entity = tile.entity;
|
||||
threads.run(() -> player.target = entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -344,7 +341,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
if(lineMode){
|
||||
int tileX = tileX(Gdx.input.getX());
|
||||
int tileY = tileY(Gdx.input.getY());
|
||||
|
||||
|
||||
//draw placing
|
||||
if(mode == placing && recipe != null){
|
||||
NormalizeDrawResult dresult = PlaceUtils.normalizeDrawArea(recipe.result, lineStartX, lineStartY, tileX, tileY, true, maxLength, lineScale);
|
||||
@@ -399,7 +396,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
Lines.rect(result.x, result.y, result.x2 - result.x, result.y2 - result.y);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
TargetTrait target = player.target;
|
||||
@@ -555,7 +552,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
//ignore off-screen taps
|
||||
if(cursor == null || ui.hasMouse(x, y)) return false;
|
||||
|
||||
checkTargets(worldx, worldy);
|
||||
threads.run(() -> checkTargets(worldx, worldy));
|
||||
|
||||
//remove if request present
|
||||
if(hasRequest(cursor)){
|
||||
|
||||
Reference in New Issue
Block a user