From c08ebc149a53802e70d2eedc6637328eb7832250 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 5 Feb 2025 10:24:44 -0500 Subject: [PATCH] Revert "Make liquid production blocks dump as much output as possible" This reverts commit 574ae0bf --- core/src/mindustry/content/Blocks.java | 4 +- .../mindustry/entities/comp/BuildingComp.java | 61 +++---------------- .../world/blocks/liquid/LiquidBridge.java | 2 +- .../world/blocks/liquid/LiquidRouter.java | 2 +- .../blocks/production/GenericCrafter.java | 2 +- 5 files changed, 15 insertions(+), 56 deletions(-) diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index ccfa1a5d61..3da006d056 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -2270,7 +2270,7 @@ public class Blocks{ liquidPadding = 6f/4f; researchCostMultiplier = 4; solid = true; - health = 600; + health = 400; }}; reinforcedLiquidTank = new LiquidRouter("reinforced-liquid-tank"){{ @@ -2279,7 +2279,7 @@ public class Blocks{ solid = true; liquidCapacity = 2700f; liquidPadding = 2f; - health = 1200; + health = 900; }}; //endregion diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index da8274ce4c..722fad3542 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -52,7 +52,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, //region vars and initialization static final float timeToSleep = 60f * 1, recentDamageTime = 60f * 5f; static final ObjectSet tmpTiles = new ObjectSet<>(); - static final Seq tempBuilds = new Seq<>(Building.class); + static final Seq tempBuilds = new Seq<>(); static final BuildTeamChangeEvent teamChangeEvent = new BuildTeamChangeEvent(); static final BuildDamageEvent bulletDamageEvent = new BuildDamageEvent(); static int sleepingEntities = 0; @@ -827,67 +827,26 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, //TODO entire liquid system is awful public void dumpLiquid(Liquid liquid){ - dumpLiquid(liquid, -1); + dumpLiquid(liquid, 2f); + } + + public void dumpLiquid(Liquid liquid, float scaling){ + dumpLiquid(liquid, scaling, -1); } /** @param outputDir output liquid direction relative to rotation, or -1 to use any direction. */ - public void dumpLiquid(Liquid liquid, int outputDir){ - float amount = liquids.get(liquid); - - if(amount <= 0.0001f) return; - - if(!net.client() && state.isCampaign() && team == state.rules.defaultTeam) liquid.unlock(); - - float sum = 0f; - tempBuilds.clear(); - - for(int i = 0; i < proximity.size; i++){ - Building other = proximity.get(i); - - if(outputDir != -1 && (outputDir + rotation) % 4 != relativeTo(other)) continue; - - other = other.getLiquidDestination(self(), liquid); - - if(other != null && other.liquids != null && canDumpLiquid(other, liquid) && other.acceptLiquid(self(), liquid)){ - //I don't want huge-capacity blocks hogging all the output, so cap their 'weight' by the amount. - sum += Math.min(amount, other.block.liquidCapacity - other.liquids.get(liquid)); - - tempBuilds.add(other); - } - } - - //nothing to output. - if(sum <= 0.00001f){ - return; - } - - var outputs = tempBuilds.items; - int outputSize = tempBuilds.size; - for(int i = 0; i < outputSize; i++){ - Building other = outputs[i]; - - float maxOutput = Math.min(amount, other.block.liquidCapacity - other.liquids.get(liquid)); - //fraction of total possible output that this block represents. - float fraction = maxOutput / sum; - - //note: transferLiquid already clamps the amount by capacity. - transferLiquid(other, fraction * amount, liquid); - } - } - - /** Tries to evenly distribute the specified liquid to nearby blocks. This method will likely be removed in the future! */ - public void distributeLiquid(Liquid liquid){ - if(liquids.get(liquid) <= 0.0001f) return; - float scaling = 2f; - + public void dumpLiquid(Liquid liquid, float scaling, int outputDir){ int dump = this.cdump; + if(liquids.get(liquid) <= 0.0001f) return; + if(!net.client() && state.isCampaign() && team == state.rules.defaultTeam) liquid.unlock(); for(int i = 0; i < proximity.size; i++){ incrementDump(proximity.size); Building other = proximity.get((i + dump) % proximity.size); + if(outputDir != -1 && (outputDir + rotation) % 4 != relativeTo(other)) continue; other = other.getLiquidDestination(self(), liquid); diff --git a/core/src/mindustry/world/blocks/liquid/LiquidBridge.java b/core/src/mindustry/world/blocks/liquid/LiquidBridge.java index 16d84058c9..984688a468 100644 --- a/core/src/mindustry/world/blocks/liquid/LiquidBridge.java +++ b/core/src/mindustry/world/blocks/liquid/LiquidBridge.java @@ -27,7 +27,7 @@ public class LiquidBridge extends ItemBridge{ @Override public void doDump(){ - dumpLiquid(liquids.current()); + dumpLiquid(liquids.current(), 1f); } } } diff --git a/core/src/mindustry/world/blocks/liquid/LiquidRouter.java b/core/src/mindustry/world/blocks/liquid/LiquidRouter.java index 3926e11d8a..020b651060 100644 --- a/core/src/mindustry/world/blocks/liquid/LiquidRouter.java +++ b/core/src/mindustry/world/blocks/liquid/LiquidRouter.java @@ -23,7 +23,7 @@ public class LiquidRouter extends LiquidBlock{ public class LiquidRouterBuild extends LiquidBuild{ @Override public void updateTile(){ - distributeLiquid(liquids.current()); + dumpLiquid(liquids.current()); } @Override diff --git a/core/src/mindustry/world/blocks/production/GenericCrafter.java b/core/src/mindustry/world/blocks/production/GenericCrafter.java index 1528cf2207..03a7b867bc 100644 --- a/core/src/mindustry/world/blocks/production/GenericCrafter.java +++ b/core/src/mindustry/world/blocks/production/GenericCrafter.java @@ -312,7 +312,7 @@ public class GenericCrafter extends Block{ for(int i = 0; i < outputLiquids.length; i++){ int dir = liquidOutputDirections.length > i ? liquidOutputDirections[i] : -1; - dumpLiquid(outputLiquids[i].liquid, dir); + dumpLiquid(outputLiquids[i].liquid, 2f, dir); } } }