Fixed place distance not being respected
This commit is contained in:
@@ -42,7 +42,7 @@ import static io.anuke.mindustry.Vars.world;
|
||||
*/
|
||||
public interface BuilderTrait extends Entity{
|
||||
//these are not instance variables!
|
||||
float placeDistance = 140f;
|
||||
float placeDistance = 150f;
|
||||
float mineDistance = 70f;
|
||||
|
||||
/**
|
||||
@@ -202,7 +202,11 @@ public interface BuilderTrait extends Entity{
|
||||
|
||||
Tile tile = world.tile(current.x, current.y);
|
||||
|
||||
if(!(tile.block() instanceof BuildBlock)){
|
||||
if(unit.distanceTo(tile) > placeDistance){
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(tile.block() instanceof BuildBlock) ){
|
||||
if(canCreateBlocks() && !current.remove && Build.validPlace(unit.getTeam(), current.x, current.y, current.recipe.result, current.rotation)){
|
||||
Build.beginPlace(unit.getTeam(), current.x, current.y, current.recipe, current.rotation);
|
||||
}else if(canCreateBlocks() && current.remove && Build.validBreak(unit.getTeam(), current.x, current.y)){
|
||||
|
||||
@@ -335,7 +335,7 @@ public abstract class InputHandler extends InputAdapter{
|
||||
}
|
||||
|
||||
public boolean validBreak(int x, int y){
|
||||
return Build.validBreak(player.getTeam(), x, y);
|
||||
return Build.validBreak(player.getTeam(), x, y) && Vector2.dst(player.x, player.y, x * tilesize, y * tilesize) < Player.placeDistance;
|
||||
}
|
||||
|
||||
public void placeBlock(int x, int y, Recipe recipe, int rotation){
|
||||
@@ -344,7 +344,6 @@ public abstract class InputHandler extends InputAdapter{
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
@@ -37,9 +37,11 @@ public class Sectors{
|
||||
logic.play();
|
||||
sector.saveID = control.getSaves().addSave("sector-" + sector.packedPosition()).index;
|
||||
world.sectors().save();
|
||||
world.setSector(sector);
|
||||
}else{
|
||||
try{
|
||||
sector.getSave().load();
|
||||
world.setSector(sector);
|
||||
state.set(State.playing);
|
||||
}catch(Exception e){
|
||||
Log.err(e);
|
||||
|
||||
@@ -149,6 +149,16 @@ public class Block extends BaseBlock implements Content{
|
||||
return blocks.get(id);
|
||||
}
|
||||
|
||||
/**Populates the array with all blocks that produce this content.*/
|
||||
public static void getByProduction(Array<Block> arr, Content content){
|
||||
arr.clear();
|
||||
for(Block block : Block.all()){
|
||||
if(block.produces.get() == content){
|
||||
arr.add(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLayer(Tile tile){
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ public class BlockPart extends Block{
|
||||
super("blockpart");
|
||||
solid = false;
|
||||
hasPower = hasItems = hasLiquids = true;
|
||||
viewRange = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user