Liquid Output Display (#6788)

* Liquid Output Display

* hshfhqwehpvoipwjovpwiqffjvpwqenoij0n89f4v123f2v40q9j8hbnwqvceinopjj90cmqwvinv21904uinfhu0bnv9j90h84g bvb8024q3bh80b3498vcfj932ndjqdjponjewopnviqvnifjwp9ghpnewuubgqjiojpdfoekwdckmpqwpkmidpkewpjndqvjwnfnj8132nt345879ytgh342890yu4598yhubn4t9hrj[tevpkofkwemfvewrphojfekpcfoerkfwmvfh23bng0398g9834ifvrfnwurbgiwnwgherhnwenhgpvrnnivjpjnipfqwjniwqfejnipofvniwejpfqjwociomjefjjmvcmj21m4f98v00ngbhegwefgpjroiewjfqfwpiojnmem

* Pull to separate function

The javadoc description could be different

* In case mods have liquid icons larger than 32x32
This commit is contained in:
dead inside
2022-05-09 14:06:55 -07:00
committed by GitHub
parent 94db45f148
commit 8269d79e56
3 changed files with 27 additions and 1 deletions

View File

@@ -1119,6 +1119,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
/** Draw the block overlay that is shown when a cursor is over the block. */
public void drawSelect(){
block.drawOverlay(x, y, rotation);
}
public void drawDisabled(){

View File

@@ -396,6 +396,7 @@ public class Block extends UnlockableContent implements Senseable{
/** Drawn when you are placing a block. */
public void drawPlace(int x, int y, int rotation, boolean valid){
drawPotentialLinks(x, y);
drawOverlay(x * tilesize + offset, y * tilesize + offset, rotation);
}
public void drawPotentialLinks(int x, int y){
@@ -444,6 +445,9 @@ public class Block extends UnlockableContent implements Senseable{
return width;
}
/** Drawn when placing and when hovering over. */
public void drawOverlay(float x, float y, int rotation){
}
public float sumAttribute(@Nullable Attribute attr, int x, int y){
if(attr == null) return 0;
Tile tile = world.tile(x, y);

View File

@@ -2,6 +2,7 @@ package mindustry.world.blocks.production;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
import arc.struct.*;
import arc.util.*;
import arc.util.io.*;
@@ -15,6 +16,8 @@ import mindustry.world.*;
import mindustry.world.draw.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
public class GenericCrafter extends Block{
/** Written to outputItems as a single-element array if outputItems is null. */
public @Nullable ItemStack outputItem;
@@ -138,6 +141,24 @@ public class GenericCrafter extends Block{
drawer.getRegionsToOutline(this, out);
}
@Override
public void drawOverlay(float x, float y, int rotation){
if(outputLiquids != null){
for(int i = 0; i < outputLiquids.length; i++){
int dir = liquidOutputDirections.length > i ? liquidOutputDirections[i] + rotation : -1;
if(dir != -1){
Draw.rect(
outputLiquids[i].liquid.fullIcon,
x + Geometry.d4x(dir) * (size * tilesize / 2f + 4),
y + Geometry.d4y(dir) * (size * tilesize / 2f + 4),
8f, 8f
);
}
}
}
}
public class GenericCrafterBuild extends Building{
public float progress;
public float totalProgress;
@@ -303,4 +324,4 @@ public class GenericCrafter extends Block{
if(legacyReadWarmup) read.f();
}
}
}
}