diff --git a/assets/bundles/bundle.properties b/assets/bundles/bundle.properties index ad575cf..4279b54 100644 --- a/assets/bundles/bundle.properties +++ b/assets/bundles/bundle.properties @@ -74,6 +74,7 @@ setting.allTeam.name = Display all teams' info on item tap setting.deadTarget.name = save locked target even if it's dead setting.linkedMass.name = Display mass driver link line setting.linkedNode.name = Display node link line +setting.distanceLine.name = Display distance line from info target #Dialog editmaxwave = Edit Waves(int) diff --git a/assets/bundles/bundle_ko.properties b/assets/bundles/bundle_ko.properties index 68dc9d3..9e1dcf8 100644 --- a/assets/bundles/bundle_ko.properties +++ b/assets/bundles/bundle_ko.properties @@ -76,6 +76,7 @@ setting.allTeam.name = 자원 탭에 모든 팀 표시 setting.deadTarget.name = 고정 목표물이 죽더라도 계속 고정하기 setting.linkedMass.name = 매스 드라이버 연결선 표시 setting.linkedNode.name = 노드 연결선 표시 +setting.distanceLine.name = 목표물과의 거리선 표시 #Dialog editmaxwave = 최대 단계 수정하기(정수) diff --git a/assets/mod.json b/assets/mod.json index f250ebb..eb6b623 100644 --- a/assets/mod.json +++ b/assets/mod.json @@ -2,10 +2,10 @@ "name": "unitinfo", "displayName": "Unit Infomation", "author": "Sharlotte", - "description": "The mod displays more information for unit, such as health, armor, shield, weapon/weapon reload etc", + "description": "The mod displays more information ingame, such as unit/building, wave, core, tile, item/unit total info etc", "version": "1.3", "main": "UnitInfo.core.Main", - "minGameVersion": "129", + "minGameVersion": "129.2", "dependencies": [], "hidden": true, "java": true diff --git a/gradle.properties b/gradle.properties index 883008f..075dd25 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,6 +3,6 @@ pArtifactFilename = UnitInfo.jar # Group of project (should line up with dirs in src/) pGroup = sharlotte # Version of Mindustry to use (if not working, consult jitpack.io) -pMindustryVersion = v129.1 +pMindustryVersion = v129.2 # Minimum API level for d8 (if you don't know what this is, leave it unless d8 yells at you) pMinApi = 26 \ No newline at end of file diff --git a/src/UnitInfo/core/HudUi.java b/src/UnitInfo/core/HudUi.java index 5ce4df2..e24a2b1 100644 --- a/src/UnitInfo/core/HudUi.java +++ b/src/UnitInfo/core/HudUi.java @@ -17,7 +17,7 @@ import arc.struct.*; import arc.util.*; import mindustry.*; import mindustry.content.*; -import mindustry.core.Renderer; +import mindustry.core.*; import mindustry.entities.*; import mindustry.entities.units.*; import mindustry.game.*; @@ -32,6 +32,7 @@ import mindustry.world.*; import mindustry.world.blocks.*; import mindustry.world.blocks.defense.turrets.*; import mindustry.world.blocks.distribution.MassDriver; +import mindustry.world.blocks.payloads.PayloadMassDriver; import mindustry.world.blocks.power.PowerNode; import mindustry.world.blocks.storage.*; @@ -75,6 +76,7 @@ public class HudUi { @Nullable Teamc target; public Seq linkedMasses = new Seq<>(); + public Seq linkedPayloadMasses = new Seq<>(); public Seq linkedNodes = new Seq<>(); @SuppressWarnings("unchecked") @@ -88,7 +90,7 @@ public class HudUi { } - Seq units = Groups.unit.intersect(Core.input.mouseWorldX(), Core.input.mouseWorldY(), 4, 4); // well, 0.5tile is enough to search them + Seq units = Groups.unit.intersect(input.mouseWorldX(), input.mouseWorldY(), 4, 4); // well, 0.5tile is enough to search them if(units.size > 0) return (T) units.peek(); //if there is unit, return it. else if(getTile() != null && getTile().build != null) @@ -99,9 +101,49 @@ public class HudUi { } public @Nullable Tile getTile(){ - return Vars.world.tileWorld(Core.input.mouseWorldX(), Core.input.mouseWorldY()); + return Vars.world.tileWorld(input.mouseWorldX(), input.mouseWorldY()); } + public void drawMassPayloadLink(PayloadMassDriver.PayloadDriverBuild from){ + Groups.build.each(b -> b instanceof PayloadMassDriver.PayloadDriverBuild fromMass && + world.build(fromMass.link) == from && + from.within(fromMass.x, fromMass.y, ((PayloadMassDriver)fromMass.block).range) && + !linkedPayloadMasses.contains(from), b -> { + linkedPayloadMasses.add((PayloadMassDriver.PayloadDriverBuild) b); + drawMassPayloadLink((PayloadMassDriver.PayloadDriverBuild) b); + }); + + if(world.build(from.link) instanceof PayloadMassDriver.PayloadDriverBuild to && from != to && + to.within(from.x, from.y, ((PayloadMassDriver)from.block).range)){ + float sin = Mathf.absin(Time.time, 6f, 1f); + Tmp.v1.set(from.x + from.block.offset, from.y + from.block.offset).sub(to.x, to.y).limit(from.block.size * tilesize + sin + 0.5f); + float x2 = from.x - Tmp.v1.x, y2 = from.y - Tmp.v1.y, + x1 = to.x + Tmp.v1.x, y1 = to.y + Tmp.v1.y; + int segs = (int)(to.dst(from.x, from.y)/tilesize); + + Lines.stroke(4f, Pal.gray); + Lines.dashLine(x1, y1, x2, y2, segs); + Lines.stroke(2f, Pal.placing); + Lines.dashLine(x1, y1, x2, y2, segs); + Lines.stroke(1f, Pal.accent); + Drawf.circles(from.x, from.y, (from.tile.block().size / 2f + 1) * tilesize + sin - 2f, Pal.accent); + + for(var shooter : from.waitingShooters){ + Drawf.circles(shooter.x, shooter.y, (from.tile.block().size / 2f + 1) * tilesize + sin - 2f); + Drawf.arrow(shooter.x, shooter.y, from.x, from.y, from.block.size * tilesize + sin, 4f + sin); + } + if(from.link != -1 && world.build(from.link) instanceof PayloadMassDriver.PayloadDriverBuild other && other.block == from.block && other.team == from.team && from.within(other, ((PayloadMassDriver)from.block).range)){ + Building target = world.build(from.link); + Drawf.circles(target.x, target.y, (target.block().size / 2f + 1) * tilesize + sin - 2f); + Drawf.arrow(from.x, from.y, target.x, target.y, from.block.size * tilesize + sin, 4f + sin); + } + if(world.build(to.link) instanceof PayloadMassDriver.PayloadDriverBuild newTo && to != newTo && + newTo.within(to.x, to.y, ((PayloadMassDriver)to.block).range) && !linkedPayloadMasses.contains(to)){ + linkedPayloadMasses.add(to); + drawMassPayloadLink(to); + } + } + } public void drawMassLink(MassDriver.MassDriverBuild from){ Groups.build.each(b -> b instanceof MassDriver.MassDriverBuild fromMass && @@ -114,7 +156,6 @@ public class HudUi { if(world.build(from.link) instanceof MassDriver.MassDriverBuild to && from != to && to.within(from.x, from.y, ((MassDriver)from.block).range)){ - float sin = Mathf.absin(Time.time, 6f, 1f); Tmp.v1.set(from.x + from.block.offset, from.y + from.block.offset).sub(to.x, to.y).limit(from.block.size * tilesize + sin + 0.5f); float x2 = from.x - Tmp.v1.x, y2 = from.y - Tmp.v1.y, @@ -138,8 +179,7 @@ public class HudUi { Drawf.arrow(from.x, from.y, target.x, target.y, from.block.size * tilesize + sin, 4f + sin); } if(world.build(to.link) instanceof MassDriver.MassDriverBuild newTo && to != newTo && - newTo.within(to.x, to.y, ((MassDriver)to.block).range) && - !linkedMasses.contains(to)){ + newTo.within(to.x, to.y, ((MassDriver)to.block).range) && !linkedMasses.contains(to)){ linkedMasses.add(to); drawMassLink(to); } @@ -180,16 +220,23 @@ public class HudUi { locked = false; } - if(settings.getBool("linkedMass") && getTarget() instanceof MassDriver.MassDriverBuild mass){ - linkedMasses.clear(); - drawMassLink(mass); + if(settings.getBool("linkedMass")){ + if(getTarget() instanceof MassDriver.MassDriverBuild mass) { + linkedMasses.clear(); + drawMassLink(mass); + } + else if(getTarget() instanceof PayloadMassDriver.PayloadDriverBuild mass) { + linkedPayloadMasses.clear(); + drawMassPayloadLink(mass); + } } + if(settings.getBool("linkedNode") && getTarget() instanceof Building node){ linkedNodes.clear(); drawNodeLink(node); } - if(Core.settings.getBool("select") && getTarget() != null) { + if(settings.getBool("select") && getTarget() != null) { Posc entity = getTarget(); for(int i = 0; i < 4; i++){ float rot = i * 90f + 45f + (-Time.time) % 360f; @@ -197,7 +244,7 @@ public class HudUi { Draw.color(Tmp.c1.set(locked ? Color.orange : Color.darkGray).lerp(locked ? Color.scarlet : Color.gray, Mathf.absin(Time.time, 2f, 1f)).a(settings.getInt("selectopacity") / 100f)); Draw.rect("select-arrow", entity.x() + Angles.trnsx(rot, length), entity.y() + Angles.trnsy(rot, length), length / 1.9f, length / 1.9f, rot - 135f); } - if(player.unit() != null && getTarget() != player.unit()) { + if(settings.getBool("distanceLine") && player.unit() != null && !player.unit().dead && getTarget() != player.unit()) { //need selected other unit with living player Teamc from = player.unit(); Teamc to = getTarget(); float sin = Mathf.absin(Time.time, 6f, 1f); @@ -208,9 +255,9 @@ public class HudUi { x1 = to.x() + Tmp.v1.x, y1 = to.y() + Tmp.v1.y; int segs = (int) (to.dst(from.x(), from.y()) / tilesize); - Lines.stroke(4f, Pal.gray); + Lines.stroke(2.5f, Pal.gray); Lines.dashLine(x1, y1, x2, y2, segs); - Lines.stroke(2f, Pal.placing); + 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 + "tiles)", @@ -246,7 +293,7 @@ public class HudUi { if(!player.unit().activelyBuilding() && player.unit().mineTile == null) { if(input.keyDown(KeyCode.mouseLeft)) { player.shooting = !boosted; - unit.aim(player.mouseX = Core.input.mouseWorldX(), player.mouseY = Core.input.mouseWorldY()); + unit.aim(player.mouseX = input.mouseWorldX(), player.mouseY = input.mouseWorldY()); } else if(target == null) { player.shooting = false; if(unit instanceof BlockUnitUnit b) { @@ -290,7 +337,7 @@ public class HudUi { public void reset(int index, Seq