Add a cap against leaking
Doesn’t fully prevent leaking, there are intentional gaps, but its significantly slower.
This commit is contained in:
@@ -135,6 +135,10 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
}
|
||||
|
||||
public float tryMoveLiquid(Tile tile, Tile next, boolean leak, Liquid liquid){
|
||||
return tryMoveLiquid(tile, next, leak ? 1.5f : 0f, liquid);
|
||||
}
|
||||
|
||||
public float tryMoveLiquid(Tile tile, Tile next, float leakrate, Liquid liquid){
|
||||
if(next == null) return 0;
|
||||
|
||||
next = next.link();
|
||||
@@ -167,8 +171,8 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if(leak && !next.block().solid && !next.block().hasLiquids){
|
||||
float leakAmount = tile.entity.liquids.get(liquid) / 1.5f;
|
||||
}else if(leakrate > 0f && !next.block().solid && !next.block().hasLiquids){
|
||||
float leakAmount = tile.entity.liquids.get(liquid) / leakrate;
|
||||
Puddle.deposit(next, tile, liquid, leakAmount);
|
||||
tile.entity.liquids.remove(liquid, leakAmount);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
protected TextureRegion[] topRegions = new TextureRegion[7];
|
||||
protected TextureRegion[] botRegions = new TextureRegion[7];
|
||||
|
||||
protected boolean leaks = true;
|
||||
protected float leakRate = 1.5f;
|
||||
|
||||
public Conduit(String name){
|
||||
super(name);
|
||||
@@ -111,7 +111,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
entity.smoothLiquid = Mathf.lerpDelta(entity.smoothLiquid, entity.liquids.total() / liquidCapacity, 0.05f);
|
||||
|
||||
if(tile.entity.liquids.total() > 0.001f && tile.entity.timer.get(timerFlow, 1)){
|
||||
tryMoveLiquid(tile, tile.getNearby(tile.rotation()), leaks, tile.entity.liquids.current());
|
||||
tryMoveLiquid(tile, tile.getNearby(tile.rotation()), leakRate, tile.entity.liquids.current());
|
||||
entity.noSleep();
|
||||
}else{
|
||||
entity.sleep();
|
||||
|
||||
@@ -1,9 +1,32 @@
|
||||
package io.anuke.mindustry.world.blocks.distribution;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
public class PlatedConduit extends Conduit{
|
||||
|
||||
protected TextureRegion capRegion;
|
||||
|
||||
public PlatedConduit(String name) {
|
||||
super(name);
|
||||
leaks = false;
|
||||
leakRate = 10f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
capRegion = Core.atlas.find(name + "-cap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile) {
|
||||
super.draw(tile);
|
||||
|
||||
Tile next = tile.getNearby(tile.rotation());
|
||||
if (next.getTeam() == tile.getTeam() && next.block().hasLiquids) return;
|
||||
|
||||
Draw.rect(capRegion, tile.drawx(), tile.drawy(), tile.rotation() * 90);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user