mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-02 04:13:44 +07:00
Side-based liquid tile padding (#8676)
This commit is contained in:
parent
9ff10e9d16
commit
38b2540677
@ -33,10 +33,15 @@ public class LiquidBlock extends Block{
|
||||
}
|
||||
|
||||
public static void drawTiledFrames(int size, float x, float y, float padding, Liquid liquid, float alpha){
|
||||
drawTiledFrames(size, x, y, padding, padding, padding, padding, liquid, alpha);
|
||||
}
|
||||
|
||||
public static void drawTiledFrames(int size, float x, float y, float padLeft, float padRight, float padTop, float padBottom, Liquid liquid, float alpha){
|
||||
TextureRegion region = renderer.fluidFrames[liquid.gas ? 1 : 0][liquid.getAnimationFrame()];
|
||||
TextureRegion toDraw = Tmp.tr1;
|
||||
|
||||
float bounds = size/2f * tilesize - padding;
|
||||
float leftBounds = size/2f * tilesize - padRight;
|
||||
float bottomBounds = size/2f * tilesize - padTop;
|
||||
Color color = Tmp.c1.set(liquid.color).a(1f);
|
||||
|
||||
for(int sx = 0; sx < size; sx++){
|
||||
@ -46,8 +51,8 @@ public class LiquidBlock extends Block{
|
||||
toDraw.set(region);
|
||||
|
||||
//truncate region if at border
|
||||
float rightBorder = relx*tilesize + padding, topBorder = rely*tilesize + padding;
|
||||
float squishX = rightBorder + tilesize/2f - bounds, squishY = topBorder + tilesize/2f - bounds;
|
||||
float rightBorder = relx*tilesize + padLeft, topBorder = rely*tilesize + padBottom;
|
||||
float squishX = rightBorder + tilesize/2f - leftBounds, squishY = topBorder + tilesize/2f - bottomBounds;
|
||||
float ox = 0f, oy = 0f;
|
||||
|
||||
if(squishX >= 8 || squishY >= 8) continue;
|
||||
|
@ -2,11 +2,13 @@ package mindustry.world.draw;
|
||||
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.liquid.*;
|
||||
|
||||
public class DrawLiquidTile extends DrawBlock{
|
||||
public Liquid drawLiquid;
|
||||
public float padding;
|
||||
public float padLeft = -1, padRight = -1, padTop = -1, padBottom = -1;
|
||||
public float alpha = 1f;
|
||||
|
||||
public DrawLiquidTile(Liquid drawLiquid, float padding){
|
||||
@ -24,6 +26,14 @@ public class DrawLiquidTile extends DrawBlock{
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
Liquid drawn = drawLiquid != null ? drawLiquid : build.liquids.current();
|
||||
LiquidBlock.drawTiledFrames(build.block.size, build.x, build.y, padding, drawn, build.liquids.get(drawn) / build.block.liquidCapacity * alpha);
|
||||
LiquidBlock.drawTiledFrames(build.block.size, build.x, build.y, padLeft, padRight, padTop, padBottom, drawn, build.liquids.get(drawn) / build.block.liquidCapacity * alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
if(padLeft < 0) padLeft = padding;
|
||||
if(padRight < 0) padRight = padding;
|
||||
if(padTop < 0) padTop = padding;
|
||||
if(padBottom < 0) padBottom = padding;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user