mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 12:09:27 +02:00
clean up
This commit is contained in:
@@ -2,8 +2,10 @@ package UnitInfo;
|
|||||||
|
|
||||||
import UnitInfo.core.*;
|
import UnitInfo.core.*;
|
||||||
import arc.files.*;
|
import arc.files.*;
|
||||||
|
import arc.graphics.g2d.TextureRegion;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
|
|
||||||
|
import static arc.Core.atlas;
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class SVars {
|
public class SVars {
|
||||||
@@ -13,4 +15,6 @@ public class SVars {
|
|||||||
public static SettingS settingAdder = new SettingS();
|
public static SettingS settingAdder = new SettingS();
|
||||||
public static HudUi hud = new HudUi();
|
public static HudUi hud = new HudUi();
|
||||||
public static PlayerParser playerinfo = new PlayerParser();
|
public static PlayerParser playerinfo = new PlayerParser();
|
||||||
|
|
||||||
|
public static TextureRegion clear = atlas.find("clear");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package UnitInfo.core;
|
package UnitInfo.core;
|
||||||
|
|
||||||
|
import UnitInfo.SVars;
|
||||||
import UnitInfo.ui.*;
|
import UnitInfo.ui.*;
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
@@ -26,8 +27,7 @@ import mindustry.graphics.*;
|
|||||||
import mindustry.input.*;
|
import mindustry.input.*;
|
||||||
import mindustry.logic.*;
|
import mindustry.logic.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.type.ammo.ItemAmmoType;
|
import mindustry.type.ammo.*;
|
||||||
import mindustry.type.ammo.PowerAmmoType;
|
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.*;
|
||||||
@@ -36,8 +36,6 @@ import mindustry.world.blocks.distribution.MassDriver;
|
|||||||
import mindustry.world.blocks.power.PowerNode;
|
import mindustry.world.blocks.power.PowerNode;
|
||||||
import mindustry.world.blocks.storage.*;
|
import mindustry.world.blocks.storage.*;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import static arc.Core.*;
|
import static arc.Core.*;
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
@@ -74,14 +72,11 @@ public class HudUi {
|
|||||||
Seq<Color> colors = Seq.with(Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear);
|
Seq<Color> colors = Seq.with(Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear);
|
||||||
Seq<Color> lastColors = Seq.with(Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear);
|
Seq<Color> lastColors = Seq.with(Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear);
|
||||||
CoresItemsDisplay coreItems = new CoresItemsDisplay(Team.baseTeams);
|
CoresItemsDisplay coreItems = new CoresItemsDisplay(Team.baseTeams);
|
||||||
|
|
||||||
@Nullable Teamc target;
|
@Nullable Teamc target;
|
||||||
|
|
||||||
public Seq<MassDriver.MassDriverBuild> linkedMasses = new Seq<>();
|
public Seq<MassDriver.MassDriverBuild> linkedMasses = new Seq<>();
|
||||||
public Seq<Building> linkedNodes = new Seq<>();
|
public Seq<Building> linkedNodes = new Seq<>();
|
||||||
|
|
||||||
boolean remoteChanged = false;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T extends Teamc> T getTarget(){
|
public <T extends Teamc> T getTarget(){
|
||||||
if(locked && lockedTarget != null) {
|
if(locked && lockedTarget != null) {
|
||||||
@@ -217,20 +212,17 @@ public class HudUi {
|
|||||||
Lines.dashLine(x1, y1, x2, y2, segs);
|
Lines.dashLine(x1, y1, x2, y2, segs);
|
||||||
Lines.stroke(2f, Pal.placing);
|
Lines.stroke(2f, Pal.placing);
|
||||||
Lines.dashLine(x1, y1, x2, y2, segs);
|
Lines.dashLine(x1, y1, x2, y2, segs);
|
||||||
Lines.stroke(1f, Pal.accent);
|
|
||||||
|
Fonts.outline.draw(Strings.fixed(to.dst(from.x(), from.y()), 2) + " (" + segs + "tiles)",
|
||||||
|
from.x() + Angles.trnsx(Angles.angle(from.x(), from.y(), to.x(), to.y()), player.unit().hitSize() + 40),
|
||||||
|
from.y() + Angles.trnsy(Angles.angle(from.x(), from.y(), to.x(), to.y()), player.unit().hitSize() + 40) - 3,
|
||||||
|
Pal.accent, 0.25f, false, Align.center);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.on(EventType.ResetEvent.class, e -> {
|
|
||||||
if(settings.getBool("allTeam")) coreItems.teams = Team.all;
|
|
||||||
else coreItems.teams = Team.baseTeams;
|
|
||||||
coreItems.resetUsed();
|
|
||||||
coreItems.tables.each(Group::clear);
|
|
||||||
});
|
|
||||||
|
|
||||||
Events.run(EventType.Trigger.update, ()->{
|
Events.run(EventType.Trigger.update, ()->{
|
||||||
if((input.keyDown(KeyCode.shiftRight) || input.keyDown(KeyCode.shiftLeft))){
|
if((input.keyDown(KeyCode.shiftRight) || input.keyDown(KeyCode.shiftLeft))){
|
||||||
if(input.keyTap(KeyCode.r)) lockButton.change();
|
if(input.keyTap(KeyCode.r)) lockButton.change();
|
||||||
@@ -246,36 +238,31 @@ public class HudUi {
|
|||||||
target = null;
|
target = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float mouseAngle = unit.angleTo(unit.aimX(), unit.aimY());
|
float mouseAngle = unit.angleTo(unit.aimX(), unit.aimY());
|
||||||
boolean aimCursor = omni && player.shooting && unit.type.hasWeapons() && unit.type.faceTarget && !boosted && unit.type.rotateShooting;
|
boolean aimCursor = omni && player.shooting && unit.type.hasWeapons() && unit.type.faceTarget && !boosted && unit.type.rotateShooting;
|
||||||
if (aimCursor) {
|
unit.lookAt(aimCursor ? mouseAngle : unit.prefRotation());
|
||||||
unit.lookAt(mouseAngle);
|
|
||||||
} else {
|
|
||||||
unit.lookAt(unit.prefRotation());
|
|
||||||
}
|
|
||||||
|
|
||||||
//update shooting if not building + not mining
|
//update shooting if not building + not mining
|
||||||
if (!player.unit().activelyBuilding() && player.unit().mineTile == null) {
|
if(!player.unit().activelyBuilding() && player.unit().mineTile == null) {
|
||||||
//autofire targeting
|
if(input.keyDown(KeyCode.mouseLeft)) {
|
||||||
if (input.keyDown(KeyCode.mouseLeft)) {
|
|
||||||
player.shooting = !boosted;
|
player.shooting = !boosted;
|
||||||
unit.aim(player.mouseX = Core.input.mouseWorldX(), player.mouseY = Core.input.mouseWorldY());
|
unit.aim(player.mouseX = Core.input.mouseWorldX(), player.mouseY = Core.input.mouseWorldY());
|
||||||
} else if (target == null) {
|
} else if(target == null) {
|
||||||
player.shooting = false;
|
player.shooting = false;
|
||||||
if (unit instanceof BlockUnitUnit b) {
|
if(unit instanceof BlockUnitUnit b) {
|
||||||
if (b.tile() instanceof ControlBlock c && !c.shouldAutoTarget()) {
|
if(b.tile() instanceof ControlBlock c && !c.shouldAutoTarget()) {
|
||||||
Building build = b.tile();
|
Building build = b.tile();
|
||||||
float range = build instanceof Ranged ? ((Ranged) build).range() : 0f;
|
float range = build instanceof Ranged ? ((Ranged) build).range() : 0f;
|
||||||
boolean targetGround = build instanceof Turret.TurretBuild && ((Turret) build.block).targetAir;
|
boolean targetGround = build instanceof Turret.TurretBuild && ((Turret) build.block).targetAir;
|
||||||
boolean targetAir = build instanceof Turret.TurretBuild && ((Turret) build.block).targetGround;
|
boolean targetAir = build instanceof Turret.TurretBuild && ((Turret) build.block).targetGround;
|
||||||
target = Units.closestTarget(build.team, build.x, build.y, range, u -> u.checkTarget(targetAir, targetGround), u -> targetGround);
|
target = Units.closestTarget(build.team, build.x, build.y, range, u -> u.checkTarget(targetAir, targetGround), u -> targetGround);
|
||||||
} else target = null;
|
}
|
||||||
} else if (unit.type != null) {
|
else target = null;
|
||||||
|
} else if(unit.type != null) {
|
||||||
float range = unit.hasWeapons() ? unit.range() : 0f;
|
float range = unit.hasWeapons() ? unit.range() : 0f;
|
||||||
target = Units.closestTarget(unit.team, unit.x, unit.y, range, u -> u.checkTarget(unit.type.targetAir, unit.type.targetGround), u -> unit.type.targetGround);
|
target = Units.closestTarget(unit.team, unit.x, unit.y, range, u -> u.checkTarget(unit.type.targetAir, unit.type.targetGround), u -> unit.type.targetGround);
|
||||||
|
|
||||||
if (unit.type.canHeal && target == null) {
|
if(unit.type.canHeal && target == null) {
|
||||||
target = Geometry.findClosest(unit.x, unit.y, indexer.getDamaged(Team.sharded));
|
target = Geometry.findClosest(unit.x, unit.y, indexer.getDamaged(Team.sharded));
|
||||||
if (target != null && !unit.within(target, range)) {
|
if (target != null && !unit.within(target, range)) {
|
||||||
target = null;
|
target = null;
|
||||||
@@ -291,6 +278,13 @@ public class HudUi {
|
|||||||
unit.controlWeapons(player.shooting && !boosted);
|
unit.controlWeapons(player.shooting && !boosted);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Events.on(EventType.ResetEvent.class, e -> {
|
||||||
|
if(settings.getBool("allTeam")) coreItems.teams = Team.all;
|
||||||
|
else coreItems.teams = Team.baseTeams;
|
||||||
|
coreItems.resetUsed();
|
||||||
|
coreItems.tables.each(Group::clear);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset(int index, Seq<Button> buttons, Label label, Table table, Table labelTable, String hud){
|
public void reset(int index, Seq<Button> buttons, Label label, Table table, Table labelTable, String hud){
|
||||||
@@ -319,12 +313,11 @@ public class HudUi {
|
|||||||
a = Mathf.lerpDelta(a, 0f, 0.025f);
|
a = Mathf.lerpDelta(a, 0f, 0.025f);
|
||||||
label.color.a = a;
|
label.color.a = a;
|
||||||
});
|
});
|
||||||
Label.LabelStyle style = new Label.LabelStyle(){{
|
label.setStyle(new Label.LabelStyle(){{
|
||||||
font = Fonts.outline;
|
font = Fonts.outline;
|
||||||
fontColor = Color.white;
|
fontColor = Color.white;
|
||||||
background = Styles.black8;
|
background = Styles.black8;
|
||||||
}};
|
}});
|
||||||
label.setStyle(style);
|
|
||||||
|
|
||||||
Table labelTable = new Table(t -> t.add(label).scaling(Scaling.fit).left().padRight(40 * 8f));
|
Table labelTable = new Table(t -> t.add(label).scaling(Scaling.fit).left().padRight(40 * 8f));
|
||||||
|
|
||||||
@@ -334,9 +327,8 @@ public class HudUi {
|
|||||||
Seq<TextureRegionDrawable> icons = Seq.with(Icon.units, Icon.fileText, Icon.commandRally, Icon.grid, Icon.copy, Icon.cancel);
|
Seq<TextureRegionDrawable> icons = Seq.with(Icon.units, Icon.fileText, Icon.commandRally, Icon.grid, Icon.copy, Icon.cancel);
|
||||||
for(int i = 0; i < buttons.size; i++){
|
for(int i = 0; i < buttons.size; i++){
|
||||||
int finalI = i;
|
int finalI = i;
|
||||||
buttons.set(i, t.button(icons.get(i), Styles.clearToggleTransi, () -> {
|
buttons.set(i, t.button(icons.get(i), Styles.clearToggleTransi, () ->
|
||||||
reset(finalI, buttons, label, table, labelTable, strs.get(finalI));
|
reset(finalI, buttons, label, table, labelTable, strs.get(finalI))).size(5*8f).get());
|
||||||
}).size(5*8f).get());
|
|
||||||
t.row();
|
t.row();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -607,11 +599,7 @@ public class HudUi {
|
|||||||
add(new Table(ttt -> {
|
add(new Table(ttt -> {
|
||||||
ttt.add(new Stack(){{
|
ttt.add(new Stack(){{
|
||||||
add(new Table(temp -> temp.add(new Image(){{
|
add(new Table(temp -> temp.add(new Image(){{
|
||||||
update(()->{
|
update(()-> setDrawable(getTarget() instanceof Unit ? Icon.defenseSmall.getRegion() : SVars.clear));
|
||||||
TextureRegion region = atlas.find("clear");
|
|
||||||
if(getTarget() instanceof Unit) region = Icon.defenseSmall.getRegion();
|
|
||||||
setDrawable(region);
|
|
||||||
});
|
|
||||||
}}.setScaling(Scaling.fit))));
|
}}.setScaling(Scaling.fit))));
|
||||||
|
|
||||||
add(new Table(temp -> {
|
add(new Table(temp -> {
|
||||||
@@ -638,7 +626,6 @@ public class HudUi {
|
|||||||
return name;
|
return name;
|
||||||
});
|
});
|
||||||
|
|
||||||
label.setFontScale(Scl.scl());
|
|
||||||
TextButton button = Elem.newButton("?", Styles.clearPartialt, () -> {
|
TextButton button = Elem.newButton("?", Styles.clearPartialt, () -> {
|
||||||
if(getTarget() instanceof Unit && ((Unit) getTarget()).type() != null)
|
if(getTarget() instanceof Unit && ((Unit) getTarget()).type() != null)
|
||||||
ui.content.show(((Unit) getTarget()).type);
|
ui.content.show(((Unit) getTarget()).type);
|
||||||
@@ -723,7 +710,7 @@ public class HudUi {
|
|||||||
table.center();
|
table.center();
|
||||||
final int jj = j+1;
|
final int jj = j+1;
|
||||||
Label label = new Label(() -> "[#" + (state.wave == j+1 ? Color.red.toString() : Pal.accent.toString()) + "]" + jj + "[]");
|
Label label = new Label(() -> "[#" + (state.wave == j+1 ? Color.red.toString() : Pal.accent.toString()) + "]" + jj + "[]");
|
||||||
label.setFontScale(Scl.scl());
|
|
||||||
t.add(label);
|
t.add(label);
|
||||||
}).size(Scl.scl(32f));
|
}).size(Scl.scl(32f));
|
||||||
|
|
||||||
@@ -769,7 +756,6 @@ public class HudUi {
|
|||||||
add(new Table(ttt -> {
|
add(new Table(ttt -> {
|
||||||
ttt.bottom().left();
|
ttt.bottom().left();
|
||||||
Label label = new Label(() -> amount + "");
|
Label label = new Label(() -> amount + "");
|
||||||
label.setFontScale(Scl.scl());
|
|
||||||
ttt.add(label);
|
ttt.add(label);
|
||||||
ttt.pack();
|
ttt.pack();
|
||||||
}));
|
}));
|
||||||
@@ -894,10 +880,8 @@ public class HudUi {
|
|||||||
if(state.rules.pvp && coreItems.teams[i] != player.team()) continue;
|
if(state.rules.pvp && coreItems.teams[i] != player.team()) continue;
|
||||||
int finalI = i;
|
int finalI = i;
|
||||||
t.table(Tex.underline2, head -> {
|
t.table(Tex.underline2, head -> {
|
||||||
head.table(label -> {
|
head.center();
|
||||||
label.center();
|
head.label(() -> "[#" + coreItems.teams[finalI].color.toString() + "]" + coreItems.teams[finalI].name + "[]");
|
||||||
label.label(() -> "[#" + coreItems.teams[finalI].color.toString() + "]" + coreItems.teams[finalI].name + "[]");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
t.row();
|
t.row();
|
||||||
for(int r = 0; r < coreamount; r++) {
|
for(int r = 0; r < coreamount; r++) {
|
||||||
|
|||||||
@@ -105,13 +105,15 @@ public class Main extends Mod {
|
|||||||
e.block instanceof TractorBeamTurret tu && (unit.isFlying() ? tu.targetAir : tu.targetGround);
|
e.block instanceof TractorBeamTurret tu && (unit.isFlying() ? tu.targetAir : tu.targetGround);
|
||||||
float range = ((BaseTurret.BaseTurretBuild) e).range();
|
float range = ((BaseTurret.BaseTurretBuild) e).range();
|
||||||
float max = range + settings.getInt("rangeRadius") * tilesize + e.block.offset;
|
float max = range + settings.getInt("rangeRadius") * tilesize + e.block.offset;
|
||||||
|
float dst = Mathf.dst(control.input.getMouseX(), control.input.getMouseY(), e.x, e.y);
|
||||||
|
|
||||||
if(Vars.player.dst(e) <= max) {
|
if(control.input.block != null && dst <= max) canHit = e.block instanceof Turret t && t.targetGround;
|
||||||
|
if(player.dst(e) <= max || (control.input.block != null && dst <= max)) {
|
||||||
if(canHit || settings.getBool("allTargetRange")){
|
if(canHit || settings.getBool("allTargetRange")){
|
||||||
if(settings.getBool("softRangeDrawing")){
|
if(settings.getBool("softRangeDrawing")){
|
||||||
Lines.stroke(1, Tmp.c1.set(canHit ? e.team.color : Team.derelict.color).a(0.5f));
|
Lines.stroke(1, Tmp.c1.set(canHit ? e.team.color : Team.derelict.color).a(0.5f));
|
||||||
Lines.poly(e.x, e.y, Lines.circleVertices(range), range);
|
Lines.poly(e.x, e.y, Lines.circleVertices(range), range);
|
||||||
Fill.light(e.x, e.y, Lines.circleVertices(range), range, Color.clear, Tmp.c1.a(Mathf.clamp(1-(Vars.player.dst(e)/max), 0, settings.getInt("softRangeOpacity")/100f)));
|
Fill.light(e.x, e.y, Lines.circleVertices(range), range, Color.clear, Tmp.c1.a(Mathf.clamp(1-((control.input.block != null && dst <= max ? dst : player.dst(e))/max), 0, settings.getInt("softRangeOpacity")/100f)));
|
||||||
}
|
}
|
||||||
else Drawf.dashCircle(e.x, e.y, range, canHit ? e.team.color : Team.derelict.color);
|
else Drawf.dashCircle(e.x, e.y, range, canHit ? e.team.color : Team.derelict.color);
|
||||||
}
|
}
|
||||||
@@ -119,8 +121,9 @@ public class Main extends Mod {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Unit Ranges (Only works when turret ranges are enabled)
|
// Unit Ranges (Only works when turret ranges are enabled)
|
||||||
if(settings.getBool("unitRange")) {
|
if(settings.getBool("unitRange") || (settings.getBool("allTeamRange") && player.unit() != null)) {
|
||||||
Groups.unit.each(u -> {
|
Groups.unit.each(u -> {
|
||||||
|
if(!settings.getBool("unitRange") && settings.getBool("allTeamRange") && player.unit() != u) return;
|
||||||
if(!settings.getBool("allTeamRange") && u.team == team) return; // Don't draw own units
|
if(!settings.getBool("allTeamRange") && u.team == team) return; // Don't draw own units
|
||||||
boolean canHit = unit.isFlying() ? u.type.targetAir : u.type.targetGround;
|
boolean canHit = unit.isFlying() ? u.type.targetAir : u.type.targetGround;
|
||||||
float range = u.range();
|
float range = u.range();
|
||||||
|
|||||||
Reference in New Issue
Block a user