autolink 2

This commit is contained in:
Anuken
2019-08-02 23:23:04 -04:00
parent 7f2cc59b3c
commit 4e308d6600
3 changed files with 8 additions and 10 deletions

View File

@@ -175,7 +175,6 @@ public class MapEditor{
world.setBlock(tile(x, y), drawBlock, drawTeam); world.setBlock(tile(x, y), drawBlock, drawTeam);
}else{ }else{
boolean isFloor = drawBlock.isFloor() && drawBlock != Blocks.air; boolean isFloor = drawBlock.isFloor() && drawBlock != Blocks.air;
Consumer<Tile> drawer = tile -> { Consumer<Tile> drawer = tile -> {

View File

@@ -281,6 +281,10 @@ public class Block extends BlockStorage{
Call.linkPowerNodes(null, tempTiles.first(), tile); Call.linkPowerNodes(null, tempTiles.first(), tile);
} }
} }
if(outputsPower && !consumesPower){
PowerNode.lastPlaced = tile.pos();
}
} }
public void removed(Tile tile){ public void removed(Tile tile){

View File

@@ -25,7 +25,7 @@ import static io.anuke.mindustry.Vars.world;
public class PowerNode extends PowerBlock{ public class PowerNode extends PowerBlock{
//last distribution block placed //last distribution block placed
private static int lastPlaced = -1; public static int lastPlaced = -1;
protected Vector2 t1 = new Vector2(), t2 = new Vector2(); protected Vector2 t1 = new Vector2(), t2 = new Vector2();
protected TextureRegion laser, laserEnd; protected TextureRegion laser, laserEnd;
@@ -105,19 +105,14 @@ public class PowerNode extends PowerBlock{
@Override @Override
public void playerPlaced(Tile tile){ public void playerPlaced(Tile tile){
super.playerPlaced(tile);
Tile before = world.tile(lastPlaced); Tile before = world.tile(lastPlaced);
if(linkValid(tile, before) && before.block() instanceof PowerNode){
for(Tile near : before.entity.proximity()){ if(linkValid(tile, before) && !before.entity.proximity().contains(tile)){
if(near == tile){
lastPlaced = tile.pos();
return;
}
}
Call.linkPowerNodes(null, tile, before); Call.linkPowerNodes(null, tile, before);
} }
lastPlaced = tile.pos(); lastPlaced = tile.pos();
super.playerPlaced(tile);
} }
@Override @Override