Side-based liquid tile padding (#8676)
This commit is contained in:
@@ -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){
|
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 region = renderer.fluidFrames[liquid.gas ? 1 : 0][liquid.getAnimationFrame()];
|
||||||
TextureRegion toDraw = Tmp.tr1;
|
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);
|
Color color = Tmp.c1.set(liquid.color).a(1f);
|
||||||
|
|
||||||
for(int sx = 0; sx < size; sx++){
|
for(int sx = 0; sx < size; sx++){
|
||||||
@@ -46,8 +51,8 @@ public class LiquidBlock extends Block{
|
|||||||
toDraw.set(region);
|
toDraw.set(region);
|
||||||
|
|
||||||
//truncate region if at border
|
//truncate region if at border
|
||||||
float rightBorder = relx*tilesize + padding, topBorder = rely*tilesize + padding;
|
float rightBorder = relx*tilesize + padLeft, topBorder = rely*tilesize + padBottom;
|
||||||
float squishX = rightBorder + tilesize/2f - bounds, squishY = topBorder + tilesize/2f - bounds;
|
float squishX = rightBorder + tilesize/2f - leftBounds, squishY = topBorder + tilesize/2f - bottomBounds;
|
||||||
float ox = 0f, oy = 0f;
|
float ox = 0f, oy = 0f;
|
||||||
|
|
||||||
if(squishX >= 8 || squishY >= 8) continue;
|
if(squishX >= 8 || squishY >= 8) continue;
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ package mindustry.world.draw;
|
|||||||
|
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.liquid.*;
|
import mindustry.world.blocks.liquid.*;
|
||||||
|
|
||||||
public class DrawLiquidTile extends DrawBlock{
|
public class DrawLiquidTile extends DrawBlock{
|
||||||
public Liquid drawLiquid;
|
public Liquid drawLiquid;
|
||||||
public float padding;
|
public float padding;
|
||||||
|
public float padLeft = -1, padRight = -1, padTop = -1, padBottom = -1;
|
||||||
public float alpha = 1f;
|
public float alpha = 1f;
|
||||||
|
|
||||||
public DrawLiquidTile(Liquid drawLiquid, float padding){
|
public DrawLiquidTile(Liquid drawLiquid, float padding){
|
||||||
@@ -24,6 +26,14 @@ public class DrawLiquidTile extends DrawBlock{
|
|||||||
@Override
|
@Override
|
||||||
public void draw(Building build){
|
public void draw(Building build){
|
||||||
Liquid drawn = drawLiquid != null ? drawLiquid : build.liquids.current();
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user