Duct blend fix / Duct autobridge

This commit is contained in:
Anuken 2021-12-01 16:01:49 -05:00
parent a31ddb7fa1
commit 99488e7c8d
5 changed files with 38 additions and 9 deletions

View File

@ -94,8 +94,10 @@ public class Blocks{
//power //power
combustionGenerator, thermalGenerator, steamGenerator, differentialGenerator, rtgGenerator, solarPanel, largeSolarPanel, thoriumReactor, combustionGenerator, thermalGenerator, steamGenerator, differentialGenerator, rtgGenerator, solarPanel, largeSolarPanel, thoriumReactor,
turbineCondenser,
impactReactor, battery, batteryLarge, powerNode, powerNodeLarge, surgeTower, diode, impactReactor, battery, batteryLarge, powerNode, powerNodeLarge, surgeTower, diode,
//power - erekir
turbineCondenser, chemicalCombustionChamber,
beamNode, beamTower, beamNode, beamTower,
//production //production
@ -1044,7 +1046,7 @@ public class Blocks{
iconOverride = new String[]{"-bottom", "", "-top1"}; iconOverride = new String[]{"-bottom", "", "-top1"};
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawLiquidRegion(), new DrawBlock(), new DrawHeatOutput()); drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawLiquidRegion(), new DrawBlock(), new DrawHeatOutput());
craftTime = 60f * 3f; craftTime = 60f * 4f;
liquidCapacity = 30f; liquidCapacity = 30f;
heatOutput = 5f; heatOutput = 5f;
}}; }};
@ -1963,6 +1965,19 @@ public class Blocks{
liquidCapacity = 20f; 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 //endregion power
//region production //region production

View File

@ -175,7 +175,7 @@ public class Placement{
plans.set(result); plans.set(result);
} }
public static void calculateBridges(Seq<BuildPlan> plans, DirectionBridge bridge){ public static void calculateBridges(Seq<BuildPlan> plans, DirectionBridge bridge, boolean hasJunction){
if(isSidePlace(plans)) return; if(isSidePlace(plans)) return;
//check for orthogonal placement + unlocked state //check for orthogonal placement + unlocked state
@ -183,8 +183,11 @@ public class Placement{
return; return;
} }
Boolf<BuildPlan> placeable = plan -> (plan.placeable(player.team())) || //TODO for chains of ducts, do not count consecutives in a different rotation as 'placeable'
(plan.tile() != null && plan.tile().block() == plan.block); //don't count the same block as inaccessible Boolf<BuildPlan> 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 result = plans1.clear();
var team = player.team(); 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))){ if(i < plans.size - 1 && placeable.get(cur) && !placeable.get(plans.get(i + 1))){
//find the closest valid position within range //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); var other = plans.get(j);
//out of range now, set to current position and keep scanning forward for next occurrence //out of range now, set to current position and keep scanning forward for next occurrence

View File

@ -63,6 +63,15 @@ public class Duct extends Block implements Autotiler{
Draw.scl(); 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 @Override
public boolean blends(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){ 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); 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 @Override
public void handlePlacementLine(Seq<BuildPlan> plans){ public void handlePlacementLine(Seq<BuildPlan> plans){
Placement.calculateBridges(plans, (DuctBridge)Blocks.ductBridge); Placement.calculateBridges(plans, (DuctBridge)Blocks.ductBridge, false);
} }
public class DuctBuild extends Building{ public class DuctBuild extends Building{

View File

@ -17,6 +17,7 @@ import mindustry.type.*;
import mindustry.world.*; import mindustry.world.*;
import mindustry.world.blocks.*; import mindustry.world.blocks.*;
import mindustry.world.blocks.distribution.Conveyor.*; import mindustry.world.blocks.distribution.Conveyor.*;
import mindustry.world.blocks.distribution.Duct.*;
import mindustry.world.meta.*; import mindustry.world.meta.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
@ -137,7 +138,8 @@ public class StackConveyor extends Block implements Autotiler{
} }
} }
}else if(state == stateUnload){ //front unload }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); Draw.rect(sliced(regions[0], SliceMode.top), x + Geometry.d4x(rotation) * tilesize*0.75f, y + Geometry.d4y(rotation) * tilesize*0.75f, rotation * 90f);
} }
} }

View File

@ -133,7 +133,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
if(bridgeReplacement == null) return; if(bridgeReplacement == null) return;
if(rotBridgeReplacement instanceof DirectionBridge duct){ if(rotBridgeReplacement instanceof DirectionBridge duct){
Placement.calculateBridges(plans, duct); Placement.calculateBridges(plans, duct, true);
}else{ }else{
Placement.calculateBridges(plans, (ItemBridge)bridgeReplacement); Placement.calculateBridges(plans, (ItemBridge)bridgeReplacement);
} }