Anuken/Mindustry-Suggestions/issues/2810
This commit is contained in:
@@ -32,6 +32,8 @@ public class Conveyor extends Block implements Autotiler{
|
||||
public float speed = 0f;
|
||||
public float displayedSpeed = 0f;
|
||||
|
||||
public @Nullable Block junctionReplacement, bridgeReplacement;
|
||||
|
||||
public Conveyor(String name){
|
||||
super(name);
|
||||
rotate = true;
|
||||
@@ -55,6 +57,14 @@ public class Conveyor extends Block implements Autotiler{
|
||||
stats.add(Stat.itemsMoved, displayedSpeed, StatUnit.itemsSecond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
super.init();
|
||||
|
||||
if(junctionReplacement == null) junctionReplacement = Blocks.junction;
|
||||
if(bridgeReplacement == null || !(bridgeReplacement instanceof ItemBridge)) bridgeReplacement = Blocks.itemBridge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan req, Eachable<BuildPlan> list){
|
||||
int[] bits = getTiling(req, list);
|
||||
@@ -79,7 +89,9 @@ public class Conveyor extends Block implements Autotiler{
|
||||
|
||||
@Override
|
||||
public void handlePlacementLine(Seq<BuildPlan> plans){
|
||||
Placement.calculateBridges(plans, (ItemBridge)Blocks.itemBridge);
|
||||
if(bridgeReplacement == null) return;
|
||||
|
||||
Placement.calculateBridges(plans, (ItemBridge)bridgeReplacement);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,12 +106,14 @@ public class Conveyor extends Block implements Autotiler{
|
||||
|
||||
@Override
|
||||
public Block getReplacement(BuildPlan req, Seq<BuildPlan> requests){
|
||||
if(junctionReplacement == null) return this;
|
||||
|
||||
Boolf<Point2> cont = p -> requests.contains(o -> o.x == req.x + p.x && o.y == req.y + p.y && (req.block instanceof Conveyor || req.block instanceof Junction));
|
||||
return cont.get(Geometry.d4(req.rotation)) &&
|
||||
cont.get(Geometry.d4(req.rotation - 2)) &&
|
||||
req.tile() != null &&
|
||||
req.tile().block() instanceof Conveyor &&
|
||||
Mathf.mod(req.tile().build.rotation - req.rotation, 2) == 1 ? Blocks.junction : this;
|
||||
Mathf.mod(req.tile().build.rotation - req.rotation, 2) == 1 ? junctionReplacement : this;
|
||||
}
|
||||
|
||||
public class ConveyorBuild extends Building implements ChainedBuilding{
|
||||
|
||||
@@ -31,6 +31,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
public @Load("@-cap") TextureRegion capRegion;
|
||||
|
||||
public boolean leaks = true;
|
||||
public @Nullable Block junctionReplacement, bridgeReplacement;
|
||||
|
||||
public Conduit(String name){
|
||||
super(name);
|
||||
@@ -41,6 +42,14 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
noUpdateDisabled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
super.init();
|
||||
|
||||
if(junctionReplacement == null) junctionReplacement = Blocks.liquidJunction;
|
||||
if(bridgeReplacement == null || !(bridgeReplacement instanceof ItemBridge)) bridgeReplacement = Blocks.bridgeConduit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan req, Eachable<BuildPlan> list){
|
||||
int[] bits = getTiling(req, list);
|
||||
@@ -58,12 +67,14 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
|
||||
@Override
|
||||
public Block getReplacement(BuildPlan req, Seq<BuildPlan> requests){
|
||||
if(junctionReplacement == null) return this;
|
||||
|
||||
Boolf<Point2> cont = p -> requests.contains(o -> o.x == req.x + p.x && o.y == req.y + p.y && o.rotation == req.rotation && (req.block instanceof Conduit || req.block instanceof LiquidJunction));
|
||||
return cont.get(Geometry.d4(req.rotation)) &&
|
||||
cont.get(Geometry.d4(req.rotation - 2)) &&
|
||||
req.tile() != null &&
|
||||
req.tile().block() instanceof Conduit &&
|
||||
Mathf.mod(req.build().rotation - req.rotation, 2) == 1 ? Blocks.liquidJunction : this;
|
||||
Mathf.mod(req.build().rotation - req.rotation, 2) == 1 ? junctionReplacement : this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,7 +84,9 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
|
||||
@Override
|
||||
public void handlePlacementLine(Seq<BuildPlan> plans){
|
||||
Placement.calculateBridges(plans, (ItemBridge)Blocks.bridgeConduit);
|
||||
if(bridgeReplacement == null) return;
|
||||
|
||||
Placement.calculateBridges(plans, (ItemBridge)bridgeReplacement);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user