mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-11 15:56:21 +02:00
block hp bar
This commit is contained in:
@@ -3,8 +3,14 @@ package informatis.ui.draws;
|
||||
import arc.graphics.g2d.Draw;
|
||||
import arc.graphics.g2d.Fill;
|
||||
import arc.scene.style.TextureRegionDrawable;
|
||||
import mindustry.Vars;
|
||||
import mindustry.gen.Building;
|
||||
import mindustry.gen.Groups;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.world.Build;
|
||||
import mindustry.world.Tile;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import static informatis.SUtils.*;
|
||||
import static arc.Core.settings;
|
||||
@@ -13,25 +19,51 @@ public class BlockDraw extends OverDraw {
|
||||
BlockDraw(String name, TextureRegionDrawable icon) {
|
||||
super(name, icon);
|
||||
registerOption("blockStatus");
|
||||
registerOption("blockBar");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
super.draw();
|
||||
Groups.build.each(b->{
|
||||
if(isInCamera(b.x, b.y, b.block.size/2f) && settings.getBool("blockStatus") && enabled) {
|
||||
if(b.block.consumers.length > 0) {
|
||||
float multiplier = b.block.size > 1 ? 1.0F : 0.64F;
|
||||
float brcx = b.x + (float)(b.block.size * 8) / 2.0F - 8.0F * multiplier / 2.0F;
|
||||
float brcy = b.y - (float)(b.block.size * 8) / 2.0F + 8.0F * multiplier / 2.0F;
|
||||
Draw.z(71.0F);
|
||||
Draw.color(Pal.gray);
|
||||
Fill.square(brcx, brcy, 2.5F * multiplier, 45.0F);
|
||||
Draw.color(b.status().color);
|
||||
Fill.square(brcx, brcy, 1.5F * multiplier, 45.0F);
|
||||
Draw.color();
|
||||
}
|
||||
};
|
||||
|
||||
if(!enabled) return;
|
||||
Groups.build.each(b -> {
|
||||
if(!isInCamera(b.x, b.y, b.block.size/2f)) return;
|
||||
if(settings.getBool("blockStatus") && b.block.consumers.length > 0) {
|
||||
float multiplier = b.block.size > 1 ? 1.0F : 0.64F;
|
||||
float brcx = b.x + (float)(b.block.size * 8) / 2.0F - 8.0F * multiplier / 2.0F;
|
||||
float brcy = b.y - (float)(b.block.size * 8) / 2.0F + 8.0F * multiplier / 2.0F;
|
||||
Draw.z(71.0F);
|
||||
Draw.color(Pal.gray);
|
||||
Fill.square(brcx, brcy, 2.5F * multiplier, 45.0F);
|
||||
Draw.color(b.status().color);
|
||||
Fill.square(brcx, brcy, 1.5F * multiplier, 45.0F);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
});
|
||||
for (Tile tile : Vars.world.tiles) {
|
||||
if(!isInCamera(tile.worldx(), tile.worldy(), 8) || tile.build == null) continue;
|
||||
|
||||
Building b = tile.build;
|
||||
|
||||
if(settings.getBool("blockBar")) {
|
||||
float bx = b.x, by = b.y - b.block.size * 4 - 2;
|
||||
float width = b.block.size * 7.5f, height = 2;
|
||||
Draw.color(Pal.gray);
|
||||
Fill.quad(
|
||||
bx - width/2, by + height/2,
|
||||
bx - width/2, by - height/2,
|
||||
bx + width/2, by - height/2,
|
||||
bx + width/2, by + height/2);
|
||||
Draw.color(Pal.health);
|
||||
width = b.block.size * 7.5f - 0.5f; height = 2 - 0.5f;
|
||||
Fill.quad(
|
||||
bx - width/2, by + height/2,
|
||||
bx - width/2, by - height/2,
|
||||
bx - width/2 + width * b.healthf(), by - height/2,
|
||||
bx - width/2 + width * b.healthf(), by + height/2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user