mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 20:19:26 +02:00
clean up, bugfix
This commit is contained in:
@@ -2,21 +2,17 @@ package UnitInfo.core;
|
||||
|
||||
import UnitInfo.ui.*;
|
||||
import arc.*;
|
||||
import arc.audio.Sound;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.graphics.gl.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.scene.Element;
|
||||
import arc.scene.Group;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.ai.*;
|
||||
import mindustry.ai.types.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.*;
|
||||
@@ -25,7 +21,6 @@ import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.defense.*;
|
||||
import mindustry.world.blocks.defense.turrets.*;
|
||||
import mindustry.world.blocks.distribution.*;
|
||||
import mindustry.world.blocks.payloads.*;
|
||||
@@ -56,84 +51,86 @@ public class OverDrawer {
|
||||
public static void setEvent(){
|
||||
Events.run(EventType.Trigger.draw, () -> {
|
||||
effectBuffer.resize(graphics.getWidth(), graphics.getHeight());
|
||||
Draw.z(Layer.max);
|
||||
|
||||
//local drawing, drawn on player/camera position
|
||||
if(settings.getBool("spawnerarrow")) {
|
||||
float leng = (player.unit() != null && player.unit().hitSize > 4 * 8f ? player.unit().hitSize * 1.5f : 4 * 8f) + sin;
|
||||
Tmp.v1.set(camera.position);
|
||||
Lines.stroke(1f + sin / 2, Pal.accent);
|
||||
Lines.circle(Tmp.v1.x, Tmp.v1.y, leng - 4f);
|
||||
spawner.getSpawns().each(t -> {
|
||||
float leng = (player.unit() != null && player.unit().hitSize > 4 * 8f ? player.unit().hitSize * 1.5f : 4 * 8f) + sin;
|
||||
|
||||
Tmp.v1.set(camera.position);
|
||||
Lines.stroke(1f + sin / 2, Pal.accent);
|
||||
Lines.circle(Tmp.v1.x, Tmp.v1.y, leng - 4f);
|
||||
Drawf.arrow(Tmp.v1.x, Tmp.v1.y, t.worldx(), t.worldy(), leng, (Math.min(200 * 8f, Mathf.dst(Tmp.v1.x, Tmp.v1.y, t.worldx(), t.worldy())) / (200 * 8f)) * (5f + sin));
|
||||
});
|
||||
}
|
||||
|
||||
if(settings.getBool("select") && target != null) {
|
||||
if(settings.getBool("select")) {
|
||||
Draw.color(Tmp.c1.set(locked ? Color.orange : Color.darkGray).lerp(locked ? Color.scarlet : Color.gray, Mathf.absin(Time.time, 3f, 1f)).a(settings.getInt("selectopacity") / 100f));
|
||||
float length = (target instanceof Unit u ? u.hitSize : target instanceof Building b ? b.block.size * tilesize : 0) * 1.5f + 2.5f;
|
||||
for(int i = 0; i < 4; i++){
|
||||
float rot = i * 90f + 45f + (-Time.time) % 360f;
|
||||
float length = (target instanceof Unit u ? u.hitSize : target instanceof Building b ? b.block.size * tilesize : 0) * 1.5f + 2.5f;
|
||||
Draw.color(Tmp.c1.set(locked ? Color.orange : Color.darkGray).lerp(locked ? Color.scarlet : Color.gray, Mathf.absin(Time.time, 3f, 1f)).a(settings.getInt("selectopacity") / 100f));
|
||||
Draw.rect("select-arrow", target.x() + Angles.trnsx(rot, length), target.y() + Angles.trnsy(rot, length), length / 1.9f, length / 1.9f, rot - 135f);
|
||||
}
|
||||
if(settings.getBool("distanceLine") && player.unit() != null && !player.unit().dead && target != null) { //need selected other unit with living player
|
||||
Teamc from = player.unit();
|
||||
Position to = target;
|
||||
if(to == from) to = input.mouseWorld();
|
||||
if(player.unit() instanceof BlockUnitUnit bu) Tmp.v1.set(bu.x() + bu.tile().block.offset, bu.y() + bu.tile().block.offset).sub(to.getX(), to.getY()).limit(bu.tile().block.size * tilesize + sin + 0.5f);
|
||||
else Tmp.v1.set(from.x(), from.y()).sub(to.getX(), to.getY()).limit(player.unit().hitSize + sin + 0.5f);
|
||||
}
|
||||
|
||||
float x2 = from.x() - Tmp.v1.x, y2 = from.y() - Tmp.v1.y,
|
||||
x1 = to.getX() + Tmp.v1.x, y1 = to.getY() + Tmp.v1.y;
|
||||
int segs = (int) (to.dst(from.x(), from.y()) / tilesize);
|
||||
if(segs > 0){
|
||||
Lines.stroke(2.5f, Pal.gray);
|
||||
Lines.dashLine(x1, y1, x2, y2, segs);
|
||||
Lines.stroke(1f, Pal.placing);
|
||||
Lines.dashLine(x1, y1, x2, y2, segs);
|
||||
if(settings.getBool("distanceLine")) {
|
||||
Posc from = player;
|
||||
Position to = target;
|
||||
if(to == from || to == null) to = input.mouseWorld();
|
||||
if(player.unit() instanceof BlockUnitUnit bu) Tmp.v1.set(bu.x() + bu.tile().block.offset, bu.y() + bu.tile().block.offset).sub(to.getX(), to.getY()).limit(bu.tile().block.size * tilesize + sin + 0.5f);
|
||||
else Tmp.v1.set(from.x(), from.y()).sub(to.getX(), to.getY()).limit((player.unit()==null?0:player.unit().hitSize) + sin + 0.5f);
|
||||
|
||||
Fonts.outline.draw(Strings.fixed(to.dst(from.x(), from.y()), 2) + " (" + segs + " " + bundle.get("tiles") + ")",
|
||||
from.x() + Angles.trnsx(Angles.angle(from.x(), from.y(), to.getX(), to.getY()), player.unit().hitSize() + Math.min(segs, 6) * 8f),
|
||||
from.y() + Angles.trnsy(Angles.angle(from.x(), from.y(), to.getX(), to.getY()), player.unit().hitSize() + Math.min(segs, 6) * 8f) - 3,
|
||||
Pal.accent, 0.25f, false, Align.center);
|
||||
}
|
||||
float x2 = from.x() - Tmp.v1.x, y2 = from.y() - Tmp.v1.y, x1 = to.getX() + Tmp.v1.x, y1 = to.getY() + Tmp.v1.y;
|
||||
int segs = (int) (to.dst(from.x(), from.y()) / tilesize);
|
||||
if(segs > 0){
|
||||
Lines.stroke(2.5f, Pal.gray);
|
||||
Lines.dashLine(x1, y1, x2, y2, segs);
|
||||
Lines.stroke(1f, Pal.placing);
|
||||
Lines.dashLine(x1, y1, x2, y2, segs);
|
||||
|
||||
Fonts.outline.draw(Strings.fixed(to.dst(from.x(), from.y()), 2) + " (" + segs + " " + bundle.get("tiles") + ")",
|
||||
from.x() + Angles.trnsx(Angles.angle(from.x(), from.y(), to.getX(), to.getY()), player.unit().hitSize() + Math.min(segs, 6) * 8f),
|
||||
from.y() + Angles.trnsy(Angles.angle(from.x(), from.y(), to.getX(), to.getY()), player.unit().hitSize() + Math.min(segs, 6) * 8f) - 3,
|
||||
Pal.accent, 0.25f, false, Align.center);
|
||||
}
|
||||
}
|
||||
|
||||
//global drawing, which needs camera-clipping
|
||||
Core.camera.bounds(Tmp.r1);
|
||||
Groups.unit.each(u -> {
|
||||
Groups.unit.each(u-> isInCamera(u.x, u.y, u.hitSize), u -> {
|
||||
UnitController c = u.controller();
|
||||
UnitCommand com = u.team.data().command;
|
||||
|
||||
if(logicLine && c instanceof LogicAI ai && (ai.control == LUnitControl.approach || ai.control == LUnitControl.move) && isInCamera(Tmp.r1, u.x, u.y, u.hitSize)) {
|
||||
if(logicLine && c instanceof LogicAI ai && (ai.control == LUnitControl.approach || ai.control == LUnitControl.move)) {
|
||||
Lines.stroke(1, u.team.color);
|
||||
Lines.line(u.x(), u.y(), ai.moveX, ai.moveY);
|
||||
Lines.stroke(0.5f + Mathf.absin(6f, 0.5f), Tmp.c1.set(Pal.logicOperations).lerp(Pal.sap, Mathf.absin(6f, 0.5f)));
|
||||
Lines.line(u.x(), u.y(), ai.controller.x, ai.controller.y);
|
||||
}
|
||||
|
||||
if(!unitLine || u.type.flying || com == UnitCommand.idle ||
|
||||
c instanceof MinerAI ||
|
||||
c instanceof BuilderAI ||
|
||||
c instanceof RepairAI ||
|
||||
c instanceof DefenderAI ||
|
||||
c instanceof FormationAI ||
|
||||
c instanceof FlyingAI) return;
|
||||
if(unitLine && !u.type.flying && com != UnitCommand.idle && !(c instanceof MinerAI || c instanceof BuilderAI || c instanceof RepairAI || c instanceof DefenderAI || c instanceof FormationAI || c instanceof FlyingAI)) {
|
||||
Lines.stroke(1, u.team.color);
|
||||
|
||||
Lines.stroke(1, u.team.color);
|
||||
|
||||
otherCores = Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != u.team);
|
||||
getNextTile(u.tileOn(), u.controller() instanceof SuicideAI ? 0 : u.pathType(), u.team, com.ordinal());
|
||||
pathTiles.filter(Objects::nonNull);
|
||||
|
||||
for(int i = 0; i < pathTiles.size; i++) {
|
||||
Tile from = pathTiles.get(i);
|
||||
Tile to = pathTiles.get(i + 1);
|
||||
if(!isInCamera(Tmp.r1, from.x, from.y)) continue;
|
||||
Lines.line(from.worldx(), from.worldy(), to.worldx(), to.worldy());
|
||||
otherCores = Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != u.team);
|
||||
getNextTile(u.tileOn(), u.controller() instanceof SuicideAI ? 0 : u.pathType(), u.team, com.ordinal());
|
||||
pathTiles.filter(Objects::nonNull);
|
||||
for(int i = 0; i < pathTiles.size; i++) {
|
||||
Tile from = pathTiles.get(i);
|
||||
Tile to = pathTiles.get(i + 1);
|
||||
if(!isInCamera(from.x, from.y)) continue;
|
||||
Lines.line(from.worldx(), from.worldy(), to.worldx(), to.worldy());
|
||||
}
|
||||
pathTiles.clear();
|
||||
}
|
||||
pathTiles.clear();
|
||||
|
||||
if(Core.settings.getBool("unithealthui"))
|
||||
FreeBar.draw(u);
|
||||
|
||||
if(!renderer.pixelator.enabled() && u.item() != null && u.itemTime > 0.01f)
|
||||
Fonts.outline.draw(u.stack.amount + "",
|
||||
u.x + Angles.trnsx(u.rotation + 180f, u.type.itemOffsetY),
|
||||
u.y + Angles.trnsy(u.rotation + 180f, u.type.itemOffsetY) - 3,
|
||||
Pal.accent, 0.25f * u.itemTime / Scl.scl(1f), false, Align.center);
|
||||
});
|
||||
|
||||
if(pathLine) spawner.getSpawns().each(t -> {
|
||||
@@ -147,61 +144,20 @@ public class OverDrawer {
|
||||
for(int i = 0; i < pathTiles.size; i++) {
|
||||
Tile from = pathTiles.get(i);
|
||||
Tile to = pathTiles.get(i + 1);
|
||||
if(!isInCamera(Tmp.r1, from.x, from.y)) continue;
|
||||
if(!isInCamera(from.x, from.y)) continue;
|
||||
Lines.line(from.worldx(), from.worldy(), to.worldx(), to.worldy());
|
||||
}
|
||||
pathTiles.clear();
|
||||
}
|
||||
});
|
||||
|
||||
Draw.z(Layer.overlayUI);
|
||||
|
||||
|
||||
if(Core.settings.getBool("blockfont")) {
|
||||
indexer.eachBlock(null, camera.position.x, camera.position.y, 400, b -> isInCamera(Tmp.r1, b.x, b.y, b.block.size/2f), b -> {
|
||||
if(b instanceof ForceProjector.ForceBuild force) {
|
||||
ForceProjector forceBlock = (ForceProjector) force.block;
|
||||
float max = forceBlock.shieldHealth + forceBlock.phaseShieldBoost * force.phaseHeat;
|
||||
|
||||
Fonts.outline.draw((int)b.health + " / " + (int)b.maxHealth,
|
||||
b.x, b.y - b.block.size * 8 * 0.25f - 2,
|
||||
Tmp.c1.set(Pal.items).lerp(Pal.health, 1-b.healthf()), (b.block.size == 1 ? 0.3f : 0.25f) * 0.25f * b.block.size, false, Align.center);
|
||||
Fonts.outline.draw((int)(max-force.buildup) + " / " + (int)max,
|
||||
b.x, b.y - b.block.size * 8 * 0.25f + 2,
|
||||
Tmp.c1.set(Pal.shield).lerp(Pal.gray, 1-((max-force.buildup) / max)), (b.block.size == 1 ? 0.3f : 0.25f) * 0.25f * b.block.size, false, Align.center);
|
||||
}
|
||||
else if(b instanceof ReloadTurret.ReloadTurretBuild || b instanceof UnitFactory.UnitFactoryBuild || b instanceof Reconstructor.ReconstructorBuild) {
|
||||
float progress = 0f;
|
||||
if(b instanceof ReloadTurret.ReloadTurretBuild turret) progress = turret.reload / ((ReloadTurret)turret.block).reloadTime * 100;
|
||||
if(b instanceof UnitFactory.UnitFactoryBuild factory) progress = factory.fraction() * 100;
|
||||
if(b instanceof Reconstructor.ReconstructorBuild reconstructor) progress = reconstructor.fraction() * 100;
|
||||
|
||||
Fonts.outline.draw((int)b.health + " / " + (int)b.maxHealth,
|
||||
b.x, b.y - b.block.size * 8 * 0.25f - 2,
|
||||
Tmp.c1.set(Pal.items).lerp(Pal.health, 1-b.healthf()), (b.block.size == 1 ? 0.3f : 0.25f) * 0.25f * b.block.size, false, Align.center);
|
||||
Fonts.outline.draw((int)progress + "%",
|
||||
b.x, b.y - b.block.size * 8 * 0.25f + 2,
|
||||
Tmp.c1.set(Color.lightGray).lerp(Pal.accent, progress/100), (b.block.size == 1 ? 0.3f : 0.25f) * 0.25f * b.block.size, false, Align.center);
|
||||
}
|
||||
else Fonts.outline.draw((int)b.health + " / " + (int)b.maxHealth,
|
||||
b.x, b.y - b.block.size * 8 * 0.25f,
|
||||
Tmp.c1.set(Pal.items).lerp(Pal.health, 1-b.healthf()), (b.block.size == 1 ? 0.3f : 0.25f) * 0.25f * b.block.size, false, Align.center);
|
||||
});
|
||||
}
|
||||
|
||||
if(Core.settings.getBool("unithealthui")) //display unit health bar
|
||||
Groups.unit.each(u->isInCamera(Tmp.r1, u.x, u.y, u.hitSize/2f), FreeBar::draw);
|
||||
|
||||
if(settings.getBool("blockstatus")) //display enemy block status
|
||||
Groups.build.each(b->isInCamera(Tmp.r1, b.x, b.y, b.block.size/2f) && Vars.player.team() == b.team, Building::drawStatus);
|
||||
Groups.build.each(b->isInCamera(b.x, b.y, b.block.size/2f) && Vars.player.team() == b.team, Building::drawStatus);
|
||||
|
||||
if(!renderer.pixelator.enabled())
|
||||
Groups.unit.each(unit -> isInCamera(Tmp.r1, unit.x, unit.y, unit.hitSize/2f) && unit.item() != null && unit.itemTime > 0.01f, unit ->
|
||||
Fonts.outline.draw(unit.stack.amount + "",
|
||||
unit.x + Angles.trnsx(unit.rotation + 180f, unit.type.itemOffsetY),
|
||||
unit.y + Angles.trnsy(unit.rotation + 180f, unit.type.itemOffsetY) - 3,
|
||||
Pal.accent, 0.25f * unit.itemTime / Scl.scl(1f), false, Align.center)
|
||||
);
|
||||
if(settings.getBool("linkedNode") && target instanceof Building node){
|
||||
linkedNodes.clear();
|
||||
drawNodeLink(node);
|
||||
}
|
||||
|
||||
if(settings.getBool("linkedMass")){
|
||||
if(target instanceof MassDriver.MassDriverBuild mass) {
|
||||
@@ -214,17 +170,10 @@ public class OverDrawer {
|
||||
}
|
||||
}
|
||||
|
||||
if(settings.getBool("linkedNode") && target instanceof Building node){
|
||||
linkedNodes.clear();
|
||||
drawNodeLink(node);
|
||||
}
|
||||
|
||||
|
||||
if(settings.getBool("rangeNearby")) {
|
||||
Unit unit = player.unit();
|
||||
tmpbuildobj.clear();
|
||||
for(Team team : Team.baseTeams) {
|
||||
|
||||
Draw.drawRange(166 + (Team.baseTeams.length-team.id) * 3, 1, () -> effectBuffer.begin(Color.clear), () -> {
|
||||
effectBuffer.end();
|
||||
effectBuffer.blit(turretRange);
|
||||
@@ -235,7 +184,8 @@ public class OverDrawer {
|
||||
Groups.build.each(b-> settings.getBool("aliceRange") || player.team() != b.team, b -> {
|
||||
if(b instanceof BaseTurret.BaseTurretBuild turret) {
|
||||
float range = turret.range();
|
||||
if (isInCamera(Tmp.r1, b.x, b.y, range)) {
|
||||
if (isInCamera(b.x, b.y, range)) {
|
||||
int index = b.team.id;
|
||||
Draw.color(b.team.color);
|
||||
|
||||
boolean valid = false;
|
||||
@@ -243,19 +193,20 @@ public class OverDrawer {
|
||||
else if (b instanceof Turret.TurretBuild build) {
|
||||
Turret t = (Turret) build.block;
|
||||
if((unit.isFlying() ? t.targetAir : t.targetGround)) valid = true;
|
||||
if(!build.hasAmmo() || !build.cons.valid()) Draw.color(Pal.gray);
|
||||
if(!build.hasAmmo() || !build.cons.valid()) index = 0;
|
||||
} else if (b instanceof TractorBeamTurret.TractorBeamBuild build) {
|
||||
TractorBeamTurret t = (TractorBeamTurret) build.block;
|
||||
if((unit.isFlying() ? t.targetAir : t.targetGround)) valid = true;
|
||||
if(!build.cons.valid()) Draw.color(Pal.gray);
|
||||
if(!build.cons.valid()) index = 0;
|
||||
}
|
||||
|
||||
if(!valid) return;
|
||||
|
||||
if(b.team==player.team()) Draw.color(player.team().color);
|
||||
if(b.team==player.team()) index = b.team.id;
|
||||
|
||||
Draw.color(Team.baseTeams[index].color);
|
||||
if (settings.getBool("RangeShader")) {
|
||||
Draw.z(166+(Team.baseTeams.length-b.team.id)*3);
|
||||
Draw.z(166+(Team.baseTeams.length-index)*3);
|
||||
Fill.poly(b.x, b.y, Lines.circleVertices(range), range);
|
||||
} else Drawf.dashCircle(b.x, b.y, range, b.team.color);
|
||||
}
|
||||
@@ -265,13 +216,13 @@ public class OverDrawer {
|
||||
});
|
||||
}
|
||||
|
||||
static boolean isInCamera(Rect rect, float x, float y) {
|
||||
return isInCamera(rect, x, y, 0);
|
||||
static boolean isInCamera(float x, float y) {
|
||||
return isInCamera(x, y, 0);
|
||||
}
|
||||
|
||||
static boolean isInCamera(Rect rect, float x, float y, float size) {
|
||||
static boolean isInCamera(float x, float y, float size) {
|
||||
Tmp.r2.setCentered(x, y, size);
|
||||
return rect.overlaps(Tmp.r2);
|
||||
return Tmp.r1.overlaps(Tmp.r2);
|
||||
}
|
||||
|
||||
public static Tile getNextTile(Tile tile, int cost, Team team, int finder) {
|
||||
|
||||
Reference in New Issue
Block a user