Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow conveyors/ducts to use duct/conveyor bridges #10179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/src/mindustry/input/Placement.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ public static boolean isSidePlace(Seq<BuildPlan> plans){
}

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
Expand Down Expand Up @@ -170,7 +170,7 @@ public static void calculateBridges(Seq<BuildPlan> plans, ItemBridge bridge, Boo
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;
Expand Down
7 changes: 4 additions & 3 deletions core/src/mindustry/world/blocks/distribution/Conveyor.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void init(){
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
Expand Down Expand Up @@ -92,8 +92,9 @@ public boolean canReplace(Block other){
@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) Placement.calculateBridges(plans, (DuctBridge)bridgeReplacement, hasJuntionReplacement, b -> b instanceof Duct || b instanceof Conveyor);
if(bridgeReplacement instanceof ItemBridge) Placement.calculateBridges(plans, (ItemBridge)bridgeReplacement, hasJuntionReplacement, b -> b instanceof Conveyor);
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions core/src/mindustry/world/blocks/distribution/Duct.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void setStats(){
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
Expand Down Expand Up @@ -106,8 +106,8 @@ public TextureRegion[] icons(){
@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) Placement.calculateBridges(plans, (ItemBridge)bridgeReplacement, false, b -> b instanceof Duct || b instanceof StackConveyor || b instanceof Conveyor);
if(bridgeReplacement instanceof DuctBridge) Placement.calculateBridges(plans, (DuctBridge)bridgeReplacement, false, b -> b instanceof Duct || b instanceof StackConveyor || b instanceof Conveyor);
}

public class DuctBuild extends Building{
Expand Down
2 changes: 1 addition & 1 deletion core/src/mindustry/world/blocks/liquid/Conduit.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void handlePlacementLine(Seq<BuildPlan> plans){
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);
}
}

Expand Down
Loading