From 7955394b37be2eac5623681a4e39f4f555692b25 Mon Sep 17 00:00:00 2001 From: sharlotte Date: Wed, 4 Aug 2021 13:41:17 +0900 Subject: [PATCH] fixed bug --- assets/bundles/bundle.properties | 7 +- assets/bundles/bundle_ko.properties | 7 +- src/UnitInfo/core/HudUi.java | 206 ++++++++++++++++++---------- src/UnitInfo/core/Main.java | 7 +- src/UnitInfo/core/SettingS.java | 7 +- 5 files changed, 147 insertions(+), 87 deletions(-) diff --git a/assets/bundles/bundle.properties b/assets/bundles/bundle.properties index ebcb713..6794c2a 100644 --- a/assets/bundles/bundle.properties +++ b/assets/bundles/bundle.properties @@ -54,8 +54,8 @@ setting.softRangeOpacity.name = Soft Range Opacity setting.softRangeOpacity.description = use the slider to set opacity of soft range. setting.rangeRadius.name = Near Range Margin setting.rangeRadius.description = set additional distances to show range. -setting.allTeamRange.name = Display Team Range -setting.allTeamRange.description = toggle to display all teams' range. +setting.allTeamRange.name = Display Player Team Range +setting.allTeamRange.description = toggle to display player team's range. setting.allTargetRange.name = Display All Target Range setting.allTargetRange.description = toggle to display all range whatever airTarget or groundTarget etc. @@ -70,7 +70,8 @@ setting.shar1.name = Change Bar Style [lightgray](made by shar)[] setting.shar2.name = Change Bar Style [lightgray](made by shar)[] setting.shar3.name = Change Bar Style [lightgray](made by shar)[] setting.gaycursor.name = Enable Mouse Trail Effect [lightgray](only for desktop)[] -setting.allTeam.name = Display all teams' item +setting.allTeam.name = Display all teams' info on item tap +setting.deadTarget.name = save locked target even if it's dead #Dialog editmaxwave = Edit Waves(int) diff --git a/assets/bundles/bundle_ko.properties b/assets/bundles/bundle_ko.properties index 98ab1e3..a64e857 100644 --- a/assets/bundles/bundle_ko.properties +++ b/assets/bundles/bundle_ko.properties @@ -48,8 +48,8 @@ setting.softRangeOpacity.name = 부드러운 사거리 투명도 setting.softRangeOpacity.description = 슬라이더로 부드러운 사거리 투명도를 조절합니다. setting.rangeRadius.name = 사거리 접근 거리 setting.rangeRadius.description = 사거리를 표시할 추가 거리를 설정합니다. -setting.allTeamRange.name = 팀 사거리 표시 -setting.allTeamRange.description = 모든 팀의 사거리를 표시합니다. +setting.allTeamRange.name = 플레이어 팀 사거리 표시 +setting.allTeamRange.description = 플레이어 팀의 사거리를 표시합니다. setting.allTargetRange.name = 모든 목표물 사거리 표시 setting.allTargetRange.description = 지상 공중 상관없이 모든 사거리를 표시합니다. @@ -72,7 +72,8 @@ setting.shar1.name = 바 스타일 변경 [lightgray](shar 만듬)[] setting.shar2.name = 바 스타일 변경 [lightgray](shar 만듬)[] setting.shar3.name = 바 스타일 변경 [lightgray](shar 만듬)[] setting.gaycursor.name = 마우스 꼬리효과 [lightgray](PC 전용)[] -setting.allTeam.name = 모든 팀 자원 표시 +setting.allTeam.name = 자원 탭에 모든 팀 표시 +setting.deadTarget.name = 고정 목표물이 죽더라도 계속 고정하기 #Dialog editmaxwave = 최대 단계 수정하기(정수) diff --git a/src/UnitInfo/core/HudUi.java b/src/UnitInfo/core/HudUi.java index 3561f74..e94ec5b 100644 --- a/src/UnitInfo/core/HudUi.java +++ b/src/UnitInfo/core/HudUi.java @@ -75,28 +75,30 @@ public class HudUi { @Nullable Teamc target; - public Seq linkedMasses = new Seq<>(); - public Seq linkedNodes = new Seq<>(); + Seq linkedMasses = new Seq<>(); + Seq linkedNodes = new Seq<>(); + + boolean remoteChanged = false; @SuppressWarnings("unchecked") public T getTarget(){ - if(locked && - (lockedTarget instanceof Unit u && u.dead) || - (lockedTarget instanceof Building b && b.dead)) { - lockedTarget = null; - locked = false; + if(locked && lockedTarget != null) { + if(settings.getBool("deadTarget") && !Groups.all.contains(e -> e == lockedTarget)) { + lockedTarget = null; + locked = false; + } + else return (T) lockedTarget; //if there is locked target, return it first. } - if(locked && lockedTarget != null) - return (T) lockedTarget; //if there is locked target, return it first. - Seq units = Groups.unit.intersect(Core.input.mouseWorldX(), Core.input.mouseWorldY(), 4, 4); // well, 0.5tile is enough to search them........ maybe? + + Seq units = Groups.unit.intersect(Core.input.mouseWorldX(), Core.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) return (T) getTile().build; //if there isn't unit but there is build, return it. else if(player.unit() instanceof BlockUnitUnit b && b.tile() != null) return (T)b.tile(); - return (T) player.unit(); //if there are not unit and not build, return player. + return (T) player.unit(); //if there aren't unit and not build, return player. } public @Nullable Tile getTile(){ @@ -176,6 +178,11 @@ public class HudUi { } public void setEvent(){ Events.run(EventType.Trigger.draw, () -> { + if(locked && lockedTarget instanceof Healthc u && u.dead()) { + lockedTarget = null; + locked = false; + } + if(getTarget() instanceof MassDriver.MassDriverBuild mass){ linkedMasses.clear(); drawMassLink(mass); @@ -185,81 +192,126 @@ public class HudUi { drawNodeLink(node); } - if(getTarget() == null || !Core.settings.getBool("select")) return; + if(getTarget() != null && Core.settings.getBool("select")) { + Posc entity = getTarget(); + for(int i = 0; i < 4; i++){ + float rot = i * 90f + 45f + (-Time.time) % 360f; + float length = (entity instanceof Unit ? ((Unit)entity).hitSize : entity instanceof Building ? ((Building)entity).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, 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()) { + Teamc from = player.unit(); + Teamc to = getTarget(); + float sin = Mathf.absin(Time.time, 6f, 1f); + if(player.unit() instanceof BlockUnitUnit bu) Tmp.v1.set(bu.x() + bu.tile().block.offset, bu.y() + bu.tile().block.offset).sub(to.x(), to.y()).limit(bu.tile().block.size * tilesize + sin + 0.5f); + else Tmp.v1.set(from.x(), from.y()).sub(to.x(), to.y()).limit(player.unit().hitSize / tilesize + sin + 0.5f); - Posc entity = getTarget(); - for(int i = 0; i < 4; i++){ - float rot = i * 90f + 45f + (-Time.time) % 360f; - float length = (entity instanceof Unit ? ((Unit)entity).hitSize : entity instanceof Building ? ((Building)entity).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, 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); - Draw.reset(); - } + 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); + } + }; + + 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, ()->{ - if((Core.input.keyDown(KeyCode.shiftRight) || Core.input.keyDown(KeyCode.shiftLeft)) && Core.input.keyTap(KeyCode.r)){ - lockButton.change(); - } - if(!settings.getBool("autoShooting")) return; - Unit unit = player.unit(); - if(unit.type == null) return; - boolean omni = unit.type.omniMovement; - boolean validHealTarget = unit.type.canHeal && target instanceof Building && ((Building)target).isValid() && target.team() == unit.team && ((Building)target).damaged() && target.within(unit, unit.type.range); - boolean boosted = (unit instanceof Mechc && unit.isFlying()); - if((unit.type != null && Units.invalidateTarget(target, unit, unit.type.range) && !validHealTarget) || state.isEditor()){ - target = null; - } - - - float mouseAngle = unit.angleTo(unit.aimX(), unit.aimY()); - boolean aimCursor = omni && player.shooting && unit.type.hasWeapons() && unit.type.faceTarget && !boosted && unit.type.rotateShooting; - if(aimCursor){ - unit.lookAt(mouseAngle); - }else{ - unit.lookAt(unit.prefRotation()); - } - - //update shooting if not building + not mining - if(!player.unit().activelyBuilding() && player.unit().mineTile == null){ - //autofire targeting - if(input.keyDown(KeyCode.mouseLeft)) { - player.shooting = !boosted; - unit.aim(player.mouseX = Core.input.mouseWorldX(), player.mouseY = Core.input.mouseWorldY()); - } else if(target == null){ - player.shooting = false; - if(unit instanceof BlockUnitUnit b){ - if(b.tile() instanceof ControlBlock c && !c.shouldAutoTarget()){ - Building build = b.tile(); - float range = build instanceof Ranged ? ((Ranged)build).range() : 0f; - boolean targetGround = build instanceof Turret.TurretBuild && ((Turret) build.block).targetAir; - 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); - } - else target = null; - } else if(unit.type != null){ - 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); - - if(unit.type.canHeal && target == null){ - target = Geometry.findClosest(unit.x, unit.y, indexer.getDamaged(Team.sharded)); - if(target != null && !unit.within(target, range)){ - target = null; - } - } - } - }else { - player.shooting = !boosted; - unit.rotation(Angles.angle(unit.x, unit.y, target.x(), target.y())); - unit.aim(target.x(), target.y()); + if((input.keyDown(KeyCode.shiftRight) || input.keyDown(KeyCode.shiftLeft))){ + if(input.keyTap(KeyCode.r)) lockButton.change(); + else if(input.keyTap(KeyCode.num1)) { + remoteChanged = true; + uiIndex = 0; + } + else if(input.keyTap(KeyCode.num2)) { + remoteChanged = true; + uiIndex = 1; + } + else if(input.keyTap(KeyCode.num3)) { + remoteChanged = true; + uiIndex = 2; + } + else if(input.keyTap(KeyCode.num4)) { + remoteChanged = true; + uiIndex = 3; + } + else if(input.keyTap(KeyCode.num5)) { + remoteChanged = true; + uiIndex = 4; + } + else if(input.keyTap(KeyCode.num6)) { + remoteChanged = true; + uiIndex = 5; } } - unit.controlWeapons(player.shooting && !boosted); + + if(settings.getBool("autoShooting")) { + Unit unit = player.unit(); + if (unit.type == null) return; + boolean omni = unit.type.omniMovement; + boolean validHealTarget = unit.type.canHeal && target instanceof Building && ((Building) target).isValid() && target.team() == unit.team && ((Building) target).damaged() && target.within(unit, unit.type.range); + boolean boosted = (unit instanceof Mechc && unit.isFlying()); + if ((unit.type != null && Units.invalidateTarget(target, unit, unit.type.range) && !validHealTarget) || state.isEditor()) { + target = null; + } + + + float mouseAngle = unit.angleTo(unit.aimX(), unit.aimY()); + boolean aimCursor = omni && player.shooting && unit.type.hasWeapons() && unit.type.faceTarget && !boosted && unit.type.rotateShooting; + if (aimCursor) { + unit.lookAt(mouseAngle); + } else { + unit.lookAt(unit.prefRotation()); + } + + //update shooting if not building + not mining + if (!player.unit().activelyBuilding() && player.unit().mineTile == null) { + //autofire targeting + if (input.keyDown(KeyCode.mouseLeft)) { + player.shooting = !boosted; + unit.aim(player.mouseX = Core.input.mouseWorldX(), player.mouseY = Core.input.mouseWorldY()); + } else if (target == null) { + player.shooting = false; + if (unit instanceof BlockUnitUnit b) { + if (b.tile() instanceof ControlBlock c && !c.shouldAutoTarget()) { + Building build = b.tile(); + float range = build instanceof Ranged ? ((Ranged) build).range() : 0f; + boolean targetGround = build instanceof Turret.TurretBuild && ((Turret) build.block).targetAir; + 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); + } else target = null; + } else if (unit.type != null) { + 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); + + if (unit.type.canHeal && target == null) { + target = Geometry.findClosest(unit.x, unit.y, indexer.getDamaged(Team.sharded)); + if (target != null && !unit.within(target, range)) { + target = null; + } + } + } + } else { + player.shooting = !boosted; + unit.rotation(Angles.angle(unit.x, unit.y, target.x(), target.y())); + unit.aim(target.x(), target.y()); + } + } + unit.controlWeapons(player.shooting && !boosted); + } }); } @@ -302,6 +354,10 @@ public class HudUi { Seq