Allow conveyors/ducts to use duct/conveyor bridges (#10179)
* Allow conveyors/ducts to use duct/conveyor bridges * Apply suggestions from code review --------- Co-authored-by: Anuken <arnukren@gmail.com>
This commit is contained in:
@@ -129,10 +129,10 @@ public class Placement{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void calculateBridges(Seq<BuildPlan> plans, ItemBridge bridge){
|
public static void calculateBridges(Seq<BuildPlan> plans, ItemBridge bridge){
|
||||||
calculateBridges(plans, bridge, t -> false);
|
calculateBridges(plans, bridge, false, t -> false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void calculateBridges(Seq<BuildPlan> plans, ItemBridge bridge, Boolf<Block> avoid){
|
public static void calculateBridges(Seq<BuildPlan> plans, ItemBridge bridge, boolean hasJunction, Boolf<Block> avoid){
|
||||||
if(isSidePlace(plans) || plans.size == 0) return;
|
if(isSidePlace(plans) || plans.size == 0) return;
|
||||||
|
|
||||||
//check for orthogonal placement + unlocked state
|
//check for orthogonal placement + unlocked state
|
||||||
@@ -170,7 +170,7 @@ public class Placement{
|
|||||||
continue outer;
|
continue outer;
|
||||||
}else if(placeable.get(other)){
|
}else if(placeable.get(other)){
|
||||||
|
|
||||||
if(wereSame){
|
if(wereSame && hasJunction){
|
||||||
//the gap is fake, it's just conveyors that can be replaced with junctions
|
//the gap is fake, it's just conveyors that can be replaced with junctions
|
||||||
i ++;
|
i ++;
|
||||||
continue outer;
|
continue outer;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
super.init();
|
super.init();
|
||||||
|
|
||||||
if(junctionReplacement == null) junctionReplacement = Blocks.junction;
|
if(junctionReplacement == null) junctionReplacement = Blocks.junction;
|
||||||
if(bridgeReplacement == null || !(bridgeReplacement instanceof ItemBridge)) bridgeReplacement = Blocks.itemBridge;
|
if(bridgeReplacement == null || !(bridgeReplacement instanceof ItemBridge || bridgeReplacement instanceof DuctBridge)) bridgeReplacement = Blocks.itemBridge;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -92,8 +92,9 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
@Override
|
@Override
|
||||||
public void handlePlacementLine(Seq<BuildPlan> plans){
|
public void handlePlacementLine(Seq<BuildPlan> plans){
|
||||||
if(bridgeReplacement == null) return;
|
if(bridgeReplacement == null) return;
|
||||||
|
boolean hasJuntionReplacement = junctionReplacement != null;
|
||||||
Placement.calculateBridges(plans, (ItemBridge)bridgeReplacement, b -> b instanceof Conveyor);
|
if(bridgeReplacement instanceof DuctBridge bridge) Placement.calculateBridges(plans, bridge, hasJuntionReplacement, b -> b instanceof Duct || b instanceof Conveyor);
|
||||||
|
if(bridgeReplacement instanceof ItemBridge bridge) Placement.calculateBridges(plans, bridge, hasJuntionReplacement, b -> b instanceof Conveyor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class Duct extends Block implements Autotiler{
|
|||||||
public void init(){
|
public void init(){
|
||||||
super.init();
|
super.init();
|
||||||
|
|
||||||
if(bridgeReplacement == null || !(bridgeReplacement instanceof DuctBridge)) bridgeReplacement = Blocks.ductBridge;
|
if(bridgeReplacement == null || !(bridgeReplacement instanceof DuctBridge || bridgeReplacement instanceof ItemBridge)) bridgeReplacement = Blocks.ductBridge;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,8 +106,8 @@ public class Duct extends Block implements Autotiler{
|
|||||||
@Override
|
@Override
|
||||||
public void handlePlacementLine(Seq<BuildPlan> plans){
|
public void handlePlacementLine(Seq<BuildPlan> plans){
|
||||||
if(bridgeReplacement == null) return;
|
if(bridgeReplacement == null) return;
|
||||||
|
if(bridgeReplacement instanceof ItemBridge bridge) Placement.calculateBridges(plans, bridge, false, b -> b instanceof Duct || b instanceof StackConveyor || b instanceof Conveyor);
|
||||||
Placement.calculateBridges(plans, (DuctBridge)bridgeReplacement, false, b -> b instanceof Duct || b instanceof StackConveyor || b instanceof Conveyor);
|
if(bridgeReplacement instanceof DuctBridge bridge) Placement.calculateBridges(plans, bridge, false, b -> b instanceof Duct || b instanceof StackConveyor || b instanceof Conveyor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DuctBuild extends Building{
|
public class DuctBuild extends Building{
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
|||||||
if(rotBridgeReplacement instanceof DirectionBridge duct){
|
if(rotBridgeReplacement instanceof DirectionBridge duct){
|
||||||
Placement.calculateBridges(plans, duct, true, b -> b instanceof Conduit);
|
Placement.calculateBridges(plans, duct, true, b -> b instanceof Conduit);
|
||||||
}else{
|
}else{
|
||||||
Placement.calculateBridges(plans, (ItemBridge)bridgeReplacement, b -> b instanceof Conduit);
|
Placement.calculateBridges(plans, (ItemBridge)bridgeReplacement, true, b -> b instanceof Conduit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user