From 99488e7c8dc86ea0c2c349cb2d145840d2e62b76 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 1 Dec 2021 16:01:49 -0500 Subject: [PATCH] Duct blend fix / Duct autobridge --- core/src/mindustry/content/Blocks.java | 19 +++++++++++++++++-- core/src/mindustry/input/Placement.java | 11 +++++++---- .../world/blocks/distribution/Duct.java | 11 ++++++++++- .../blocks/distribution/StackConveyor.java | 4 +++- .../world/blocks/liquid/Conduit.java | 2 +- 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 4fd8515d29..ff8bcae5b8 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -94,8 +94,10 @@ public class Blocks{ //power combustionGenerator, thermalGenerator, steamGenerator, differentialGenerator, rtgGenerator, solarPanel, largeSolarPanel, thoriumReactor, - turbineCondenser, impactReactor, battery, batteryLarge, powerNode, powerNodeLarge, surgeTower, diode, + + //power - erekir + turbineCondenser, chemicalCombustionChamber, beamNode, beamTower, //production @@ -1044,7 +1046,7 @@ public class Blocks{ iconOverride = new String[]{"-bottom", "", "-top1"}; drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawLiquidRegion(), new DrawBlock(), new DrawHeatOutput()); - craftTime = 60f * 3f; + craftTime = 60f * 4f; liquidCapacity = 30f; heatOutput = 5f; }}; @@ -1963,6 +1965,19 @@ public class Blocks{ liquidCapacity = 20f; }}; + //TODO arkycite combustion: ozone + arkycite + + if(false) + chemicalCombustionChamber = new ItemLiquidGenerator("chemical-combustion-chamber"){{ + requirements(Category.power, with(Items.graphite, 30, Items.tungsten, 40, Items.silicon, 30)); + powerProduction = 6f; + consumes.liquids(LiquidStack.with(Liquids.ozone, 1f / 60f, Liquids.arkycite, 20f / 60f)); + size = 3; + + ambientSound = Sounds.smelter; + ambientSoundVolume = 0.06f; + }}; + //endregion power //region production diff --git a/core/src/mindustry/input/Placement.java b/core/src/mindustry/input/Placement.java index b15c205cec..491b57e9ad 100644 --- a/core/src/mindustry/input/Placement.java +++ b/core/src/mindustry/input/Placement.java @@ -175,7 +175,7 @@ public class Placement{ plans.set(result); } - public static void calculateBridges(Seq plans, DirectionBridge bridge){ + public static void calculateBridges(Seq plans, DirectionBridge bridge, boolean hasJunction){ if(isSidePlace(plans)) return; //check for orthogonal placement + unlocked state @@ -183,8 +183,11 @@ public class Placement{ return; } - Boolf placeable = plan -> (plan.placeable(player.team())) || - (plan.tile() != null && plan.tile().block() == plan.block); //don't count the same block as inaccessible + //TODO for chains of ducts, do not count consecutives in a different rotation as 'placeable' + Boolf placeable = plan -> + !(!hasJunction && plan.build() != null && plan.build().block == plan.block && plan.rotation != plan.build().rotation) && + (plan.placeable(player.team()) || + (plan.tile() != null && plan.tile().block() == plan.block)); //don't count the same block as inaccessible var result = plans1.clear(); var team = player.team(); @@ -198,7 +201,7 @@ public class Placement{ if(i < plans.size - 1 && placeable.get(cur) && !placeable.get(plans.get(i + 1))){ //find the closest valid position within range - for(int j = i + 1; j < plans.size; j++){ + for(int j = i + 2; j < plans.size; j++){ var other = plans.get(j); //out of range now, set to current position and keep scanning forward for next occurrence diff --git a/core/src/mindustry/world/blocks/distribution/Duct.java b/core/src/mindustry/world/blocks/distribution/Duct.java index 215468e316..cf023c2cc2 100644 --- a/core/src/mindustry/world/blocks/distribution/Duct.java +++ b/core/src/mindustry/world/blocks/distribution/Duct.java @@ -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 plans){ - Placement.calculateBridges(plans, (DuctBridge)Blocks.ductBridge); + Placement.calculateBridges(plans, (DuctBridge)Blocks.ductBridge, false); } public class DuctBuild extends Building{ diff --git a/core/src/mindustry/world/blocks/distribution/StackConveyor.java b/core/src/mindustry/world/blocks/distribution/StackConveyor.java index 8cb6cb0570..0d8da3e3d9 100644 --- a/core/src/mindustry/world/blocks/distribution/StackConveyor.java +++ b/core/src/mindustry/world/blocks/distribution/StackConveyor.java @@ -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); } } diff --git a/core/src/mindustry/world/blocks/liquid/Conduit.java b/core/src/mindustry/world/blocks/liquid/Conduit.java index 75f50a2d10..87bb5c81a1 100644 --- a/core/src/mindustry/world/blocks/liquid/Conduit.java +++ b/core/src/mindustry/world/blocks/liquid/Conduit.java @@ -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); }