Revert "Make liquid production blocks dump as much output as possible"

This reverts commit 574ae0bf
This commit is contained in:
Anuken
2025-02-05 10:24:44 -05:00
parent 389195074c
commit c08ebc149a
5 changed files with 15 additions and 56 deletions

View File

@@ -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

View File

@@ -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<Building> tmpTiles = new ObjectSet<>();
static final Seq<Building> tempBuilds = new Seq<>(Building.class);
static final Seq<Building> 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);

View File

@@ -27,7 +27,7 @@ public class LiquidBridge extends ItemBridge{
@Override
public void doDump(){
dumpLiquid(liquids.current());
dumpLiquid(liquids.current(), 1f);
}
}
}

View File

@@ -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

View File

@@ -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);
}
}
}