Duct blend fix / Duct autobridge

This commit is contained in:
Anuken
2021-12-01 16:01:49 -05:00
parent a31ddb7fa1
commit 99488e7c8d
5 changed files with 38 additions and 9 deletions

View File

@@ -63,6 +63,15 @@ public class Duct extends Block implements Autotiler{
Draw.scl();
}
@Override
public boolean blendsArmored(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){
return Point2.equals(tile.x + Geometry.d4(rotation).x, tile.y + Geometry.d4(rotation).y, otherx, othery)
|| ((!otherblock.rotatedOutput(otherx, othery) && Edges.getFacingEdge(otherblock, otherx, othery, tile) != null &&
Edges.getFacingEdge(otherblock, otherx, othery, tile).relativeTo(tile) == rotation) ||
//basically the only change here is that it treats overflow ducts specially, since they're... weird
((otherblock.rotatedOutput(otherx, othery) || otherblock instanceof OverflowDuct) && Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y)));
}
@Override
public boolean blends(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){
return (otherblock.outputsItems() && blendsArmored(tile, rotation, otherx, othery, otherrot, otherblock)) || (lookingAt(tile, rotation, otherx, othery, otherblock) && otherblock.hasItems);
@@ -75,7 +84,7 @@ public class Duct extends Block implements Autotiler{
@Override
public void handlePlacementLine(Seq<BuildPlan> plans){
Placement.calculateBridges(plans, (DuctBridge)Blocks.ductBridge);
Placement.calculateBridges(plans, (DuctBridge)Blocks.ductBridge, false);
}
public class DuctBuild extends Building{

View File

@@ -17,6 +17,7 @@ import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.blocks.*;
import mindustry.world.blocks.distribution.Conveyor.*;
import mindustry.world.blocks.distribution.Duct.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
@@ -137,7 +138,8 @@ public class StackConveyor extends Block implements Autotiler{
}
}
}else if(state == stateUnload){ //front unload
if((blendprox & (1)) != 0){
//TOOD hacky front check
if((blendprox & (1)) != 0 && !(front() instanceof DuctBuild)){
Draw.rect(sliced(regions[0], SliceMode.top), x + Geometry.d4x(rotation) * tilesize*0.75f, y + Geometry.d4y(rotation) * tilesize*0.75f, rotation * 90f);
}
}

View File

@@ -133,7 +133,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
if(bridgeReplacement == null) return;
if(rotBridgeReplacement instanceof DirectionBridge duct){
Placement.calculateBridges(plans, duct);
Placement.calculateBridges(plans, duct, true);
}else{
Placement.calculateBridges(plans, (ItemBridge)bridgeReplacement);
}