Move capping code from armored to normal conduits (#4979)

This commit is contained in:
Patrick 'Quezler' Mounier 2021-07-20 17:05:35 +02:00 committed by GitHub
parent b2ed0ee884
commit 232415f1d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 14 deletions

View File

@ -1,13 +1,10 @@
package mindustry.world.blocks.liquid;
import arc.graphics.g2d.*;
import mindustry.annotations.Annotations.*;
import mindustry.gen.*;
import mindustry.type.*;
import mindustry.world.*;
public class ArmoredConduit extends Conduit{
public @Load("@-cap") TextureRegion capRegion;
public ArmoredConduit(String name){
super(name);
@ -21,17 +18,6 @@ public class ArmoredConduit extends Conduit{
}
public class ArmoredConduitBuild extends ConduitBuild{
@Override
public void draw(){
super.draw();
//draw the cap when a conduit would normally leak
Building next = front();
if(next != null && next.team == team && next.block.hasLiquids) return;
Draw.rect(capRegion, x, y, rotdeg());
}
@Override
public boolean acceptLiquid(Building source, Liquid liquid){
return super.acceptLiquid(source, liquid) && (source.block instanceof Conduit ||

View File

@ -28,6 +28,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
public @Load(value = "@-top-#", length = 5) TextureRegion[] topRegions;
public @Load(value = "@-bottom-#", length = 5, fallback = "conduit-bottom-#") TextureRegion[] botRegions;
public @Load("@-cap") TextureRegion capRegion;
public boolean leaks = true;
@ -83,6 +84,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
public class ConduitBuild extends LiquidBuild implements ChainedBuilding{
public float smoothLiquid;
public int blendbits, xscl, yscl, blending;
public boolean capped;
@Override
public void draw(){
@ -104,6 +106,8 @@ public class Conduit extends LiquidBlock implements Autotiler{
Draw.scl(xscl, yscl);
drawAt(x, y, blendbits, rotation, SliceMode.none);
Draw.reset();
if(capped && capRegion.found()) Draw.rect(capRegion, x, y, rotdeg());
}
protected void drawAt(float x, float y, int bits, float rotation, SliceMode slice){
@ -124,6 +128,9 @@ public class Conduit extends LiquidBlock implements Autotiler{
xscl = bits[1];
yscl = bits[2];
blending = bits[4];
Building next = front();
capped = next == null || next.team != team || !next.block.hasLiquids;
}
@Override