Fixed a minor cursor bug, changed drill/pump place verification

This commit is contained in:
Anuken
2018-06-14 18:36:55 -04:00
parent fab3704dbd
commit ba67c01dd0
6 changed files with 40 additions and 31 deletions

View File

@@ -29,7 +29,6 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
private static Vector2 vector = new Vector2(); private static Vector2 vector = new Vector2();
//private Interpolator interpolator = new Interpolator();
private Team team; private Team team;
public Timer timer = new Timer(3); public Timer timer = new Timer(3);

View File

@@ -159,7 +159,11 @@ public class DesktopInput extends InputHandler{
cursorType = cursor.block().getCursor(cursor); cursorType = cursor.block().getCursor(cursor);
if(canMine(cursor)){ if(isPlacing()){
cursorType = hand;
}
if(!isPlacing() && canMine(cursor)){
cursorType = drill; cursorType = drill;
} }

View File

@@ -191,7 +191,7 @@ public class Build {
for (int dx = 0; dx < type.size; dx++) { for (int dx = 0; dx < type.size; dx++) {
for (int dy = 0; dy < type.size; dy++) { for (int dy = 0; dy < type.size; dy++) {
Tile other = world.tile(x + dx + offsetx, y + dy + offsety); Tile other = world.tile(x + dx + offsetx, y + dy + offsety);
if (other == null || (other.block() != Blocks.air && !other.block().alwaysReplace) || other.cliffs != 0 || !other.floor().placeableOn) { if (other == null || (other.block() != Blocks.air && !other.block().alwaysReplace) || !type.canPlaceOn(other) || other.cliffs != 0 || !other.floor().placeableOn) {
return false; return false;
} }
} }

View File

@@ -174,25 +174,18 @@ public class Drill extends Block{
} }
@Override @Override
public boolean isLayer(Tile tile){ public boolean canPlaceOn(Tile tile) {
if(isMultiblock()){ if(isMultiblock()){
for(Tile other : tile.getLinkedTiles(drawTiles)){ for(Tile other : tile.getLinkedTiles(drawTiles)){
if(isValid(other)){ if(isValid(other)){
return false; return true;
} }
} }
return true; return false;
}else{ }else{
return !isValid(tile); return isValid(tile);
} }
} }
@Override
public void drawLayer(Tile tile){
Draw.colorl(0.85f + Mathf.absin(Timers.time(), 6f, 0.15f));
Draw.rect("cross-" + size, tile.drawx(), tile.drawy());
Draw.color();
}
@Override @Override
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount) { public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount) {
@@ -204,6 +197,10 @@ public class Drill extends Block{
return new DrillEntity(); return new DrillEntity();
} }
protected boolean isValid(Tile tile){
return tile.floor().drops != null && tile.floor().drops.item.hardness <= tier;
}
public static class DrillEntity extends TileEntity{ public static class DrillEntity extends TileEntity{
public float progress; public float progress;
public int index; public int index;
@@ -211,8 +208,4 @@ public class Drill extends Block{
public float drillTime; public float drillTime;
} }
protected boolean isValid(Tile tile){
return tile.floor().drops != null && tile.floor().drops.item.hardness <= tier;
}
} }

View File

@@ -1,17 +1,19 @@
package io.anuke.mindustry.world.blocks.production; package io.anuke.mindustry.world.blocks.production;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import io.anuke.mindustry.type.Liquid; import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.world.meta.BlockGroup;
import io.anuke.mindustry.graphics.Layer; import io.anuke.mindustry.graphics.Layer;
import io.anuke.mindustry.type.Liquid;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.LiquidBlock; import io.anuke.mindustry.world.blocks.LiquidBlock;
import io.anuke.mindustry.world.meta.BlockGroup;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Strings; import io.anuke.ucore.util.Strings;
public class Pump extends LiquidBlock{ public class Pump extends LiquidBlock{
protected final Array<Tile> drawTiles = new Array<>();
protected float pumpAmount = 1f; protected float pumpAmount = 1f;
public Pump(String name) { public Pump(String name) {
@@ -49,15 +51,17 @@ public class Pump extends LiquidBlock{
} }
@Override @Override
public boolean isLayer(Tile tile) { public boolean canPlaceOn(Tile tile) {
return tile.floor().liquidDrop == null; if(isMultiblock()){
} for(Tile other : tile.getLinkedTiles(drawTiles)){
if(isValid(other)){
@Override return true;
public void drawLayer(Tile tile){ }
Draw.colorl(0.85f + Mathf.absin(Timers.time(), 6f, 0.15f)); }
Draw.rect("cross-"+size, tile.drawx(), tile.drawy()); return false;
Draw.color(); }else{
return isValid(tile);
}
} }
@Override @Override
@@ -72,4 +76,8 @@ public class Pump extends LiquidBlock{
tryDumpLiquid(tile); tryDumpLiquid(tile);
} }
protected boolean isValid(Tile tile){
return tile.floor().liquidDrop != null;
}
} }

View File

@@ -39,6 +39,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
import static io.anuke.mindustry.Vars.headless; import static io.anuke.mindustry.Vars.headless;
public class KryoServer implements ServerProvider { public class KryoServer implements ServerProvider {
final boolean tcpOnly = System.getProperty("java.version") == null;
final Server server; final Server server;
final ByteSerializer serializer = new ByteSerializer(); final ByteSerializer serializer = new ByteSerializer();
final ByteBuffer buffer = ByteBuffer.allocate(4096); final ByteBuffer buffer = ByteBuffer.allocate(4096);
@@ -142,7 +143,11 @@ public class KryoServer implements ServerProvider {
lastconnection = 0; lastconnection = 0;
connections.clear(); connections.clear();
missing.clear(); missing.clear();
server.bind(port, port); if(tcpOnly){
server.bind(port);
}else{
server.bind(port, port);
}
webServer = new SocketServer(Vars.webPort); webServer = new SocketServer(Vars.webPort);
webServer.start(); webServer.start();