mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-09 20:29:06 +07:00
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:
parent
73bde0d3af
commit
5f8f0140a2
@ -129,10 +129,10 @@ public class Placement{
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
//check for orthogonal placement + unlocked state
|
||||
@ -170,7 +170,7 @@ public class Placement{
|
||||
continue outer;
|
||||
}else if(placeable.get(other)){
|
||||
|
||||
if(wereSame){
|
||||
if(wereSame && hasJunction){
|
||||
//the gap is fake, it's just conveyors that can be replaced with junctions
|
||||
i ++;
|
||||
continue outer;
|
||||
|
@ -64,7 +64,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
super.init();
|
||||
|
||||
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
|
||||
@ -92,8 +92,9 @@ public class Conveyor extends Block implements Autotiler{
|
||||
@Override
|
||||
public void handlePlacementLine(Seq<BuildPlan> plans){
|
||||
if(bridgeReplacement == null) return;
|
||||
|
||||
Placement.calculateBridges(plans, (ItemBridge)bridgeReplacement, b -> b instanceof Conveyor);
|
||||
boolean hasJuntionReplacement = junctionReplacement != null;
|
||||
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
|
||||
|
@ -62,7 +62,7 @@ public class Duct extends Block implements Autotiler{
|
||||
public void 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
|
||||
@ -106,8 +106,8 @@ public class Duct extends Block implements Autotiler{
|
||||
@Override
|
||||
public void handlePlacementLine(Seq<BuildPlan> plans){
|
||||
if(bridgeReplacement == null) return;
|
||||
|
||||
Placement.calculateBridges(plans, (DuctBridge)bridgeReplacement, false, b -> b instanceof Duct || b instanceof StackConveyor || b instanceof Conveyor);
|
||||
if(bridgeReplacement instanceof ItemBridge bridge) Placement.calculateBridges(plans, bridge, 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{
|
||||
|
@ -140,7 +140,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
if(rotBridgeReplacement instanceof DirectionBridge duct){
|
||||
Placement.calculateBridges(plans, duct, true, b -> b instanceof Conduit);
|
||||
}else{
|
||||
Placement.calculateBridges(plans, (ItemBridge)bridgeReplacement, b -> b instanceof Conduit);
|
||||
Placement.calculateBridges(plans, (ItemBridge)bridgeReplacement, true, b -> b instanceof Conduit);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user