block hp bar

This commit is contained in:
Sharlotte
2022-09-22 05:42:09 +09:00
parent 9c865b863d
commit 7280cf2ce6
4 changed files with 54 additions and 16 deletions

View File

@@ -33,6 +33,9 @@ setting.baropacity.description = Sets the opacity of the unit health bar.
setting.blockStatus.name = enable Block Status
setting.blockStatus.description = display enemy block status too
setting.blockBar.name = enable Block Bar
setting.blockBar.description = display block health bar
setting.powerNode.name = enable Power Node
setting.powerNode.description = display power node link lines
setting.massDriver.name = enable Mass Driver

View File

@@ -32,7 +32,10 @@ setting.baropacity.name = 유닛 바 투명도
setting.baropacity.description = 유닛 바의 투명도를 조절합니다.
setting.blockStatus.name = 블록 상태 표시
setting.blockStatus.description = 블록 왼쪽아래에 상태를 표시합니다.
setting.blockStatus.description = 블록 상태를 표시합니다.
setting.blockBar.name = 블록 바 표시
setting.blockBar.description = 블록 체력바를 표시합니다.
setting.powerNode.name = 노드 연결선 표시
setting.powerNode.description = 선택한 블록과 전기적으로 연결된 블록들을 선으로 이어서 표시합니다.
setting.massDriver.name = 매스 드라이버 연결선 표시

View File

@@ -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,14 +19,17 @@ public class BlockDraw extends OverDraw {
BlockDraw(String name, TextureRegionDrawable icon) {
super(name, icon);
registerOption("blockStatus");
registerOption("blockBar");
}
@Override
public void draw() {
super.draw();
if(!enabled) return;
Groups.build.each(b -> {
if(isInCamera(b.x, b.y, b.block.size/2f) && settings.getBool("blockStatus") && enabled) {
if(b.block.consumers.length > 0) {
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;
@@ -31,7 +40,30 @@ public class BlockDraw extends OverDraw {
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);
}
}
}
}

View File

@@ -62,7 +62,7 @@ public class UnitDraw extends OverDraw {
pathTiles.clear();
otherCores = Groups.build.copy(new Seq<>()).filter(b -> b instanceof CoreBlock.CoreBuild && b.team != u.team);
getNextTile(u.tileOn(), SVars.pathfinder.getField(u.team, u.controller() instanceof SuicideAI ? 0 : u.pathType(), u.pathType()));
getNextTile(u.tileOn(), SVars.pathfinder.getField(u.team, u.controller() instanceof SuicideAI ? 0 : u.pathType(), Pathfinder.fieldCore));
for(int i = 0; i < pathTiles.size - 1; i++) {
Tile from = pathTiles.get(i), to = pathTiles.get(i + 1);
if(from == null || to == null) continue;