From 232415f1d7f20e4ddace87e4a65d35d5f2432e76 Mon Sep 17 00:00:00 2001 From: Patrick 'Quezler' Mounier Date: Tue, 20 Jul 2021 17:05:35 +0200 Subject: [PATCH] Move capping code from armored to normal conduits (#4979) --- .../world/blocks/liquid/ArmoredConduit.java | 14 -------------- .../src/mindustry/world/blocks/liquid/Conduit.java | 7 +++++++ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/core/src/mindustry/world/blocks/liquid/ArmoredConduit.java b/core/src/mindustry/world/blocks/liquid/ArmoredConduit.java index e404b36b44..d8f480836c 100644 --- a/core/src/mindustry/world/blocks/liquid/ArmoredConduit.java +++ b/core/src/mindustry/world/blocks/liquid/ArmoredConduit.java @@ -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 || diff --git a/core/src/mindustry/world/blocks/liquid/Conduit.java b/core/src/mindustry/world/blocks/liquid/Conduit.java index 393af2e8e5..dc0f03767e 100644 --- a/core/src/mindustry/world/blocks/liquid/Conduit.java +++ b/core/src/mindustry/world/blocks/liquid/Conduit.java @@ -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