diff --git a/assets/bundles/bundle.properties b/assets/bundles/bundle.properties index 42f9da1..31ba180 100644 --- a/assets/bundles/bundle.properties +++ b/assets/bundles/bundle.properties @@ -50,7 +50,7 @@ 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.allTargetRange.name = Display All Range -setting.allTargetRange.description = toggle to display all target range whatever airTarget or groundTarget. +setting.allTargetRange.description = toggle to display all range whatever airTarget or groundTarget or having ammo etc. setting.autoShooting.name = Enable Auto Shooting setting.infoui.name = Display Info UI diff --git a/assets/bundles/bundle_ko.properties b/assets/bundles/bundle_ko.properties index d2800ae..29dfcab 100644 --- a/assets/bundles/bundle_ko.properties +++ b/assets/bundles/bundle_ko.properties @@ -44,7 +44,7 @@ setting.rangeRadius.description = 사거리를 표시할 추가 거리를 설정 setting.allTeamRange.name = 팀 사거리 표시 setting.allTeamRange.description = 모든 팀의 사거리를 표시합니다. setting.allTargetRange.name = 모든 사거리 표시 -setting.allTargetRange.description = 지상 공중 상관없이 모든 사거리를 표시합니다. +setting.allTargetRange.description = 지상 공중 탄약 등 상관없이 모든 사거리를 표시합니다. setting.selectopacity.name = 선택 화살표 투명도 diff --git a/src/UnitInfo/core/Main.java b/src/UnitInfo/core/Main.java index 77bd463..5802889 100644 --- a/src/UnitInfo/core/Main.java +++ b/src/UnitInfo/core/Main.java @@ -16,20 +16,25 @@ import arc.util.Time; import arc.util.Tmp; import mindustry.Vars; import mindustry.content.Fx; +import mindustry.content.UnitTypes; import mindustry.game.EventType.*; import mindustry.game.Team; +import mindustry.gen.Building; import mindustry.gen.Groups; +import mindustry.gen.Teamc; import mindustry.gen.Unit; import mindustry.graphics.Drawf; import mindustry.graphics.Layer; import mindustry.graphics.Pal; import mindustry.logic.Ranged; import mindustry.mod.Mod; +import mindustry.type.UnitType; import mindustry.ui.Fonts; import mindustry.world.Block; import mindustry.world.blocks.ConstructBlock; import mindustry.world.blocks.defense.turrets.BaseTurret; import mindustry.world.blocks.defense.turrets.PointDefenseTurret; +import mindustry.world.blocks.defense.turrets.TractorBeamTurret; import mindustry.world.blocks.defense.turrets.Turret; import static UnitInfo.SVars.*; @@ -111,24 +116,45 @@ public class Main extends Mod { Draw.reset(); }); - if(settings.getBool("rangeNearby")) { + if(settings.getBool("rangeNearby") && player != null) { Groups.all.each(entityc -> - (entityc instanceof BaseTurret.BaseTurretBuild || (settings.getBool("unitRange") && entityc instanceof Unit)) && player != null - && (settings.getBool("allTeamRange") || (player.team() != ((Ranged) entityc).team() && ((Ranged) entityc).team() != Team.derelict)), entityc -> { - if(entityc instanceof PointDefenseTurret.PointDefenseBuild || ((entityc instanceof ConstructBlock.ConstructBuild && ((ConstructBlock.ConstructBuild)entityc).current instanceof Turret && (settings.getBool("allTargetRange") || - !(player.unit().isFlying() && ((Turret)((ConstructBlock.ConstructBuild)entityc).current).targetAir) || - !(player.unit().isFlying() && ((Turret)((ConstructBlock.ConstructBuild)entityc).current).targetGround))) || - (entityc instanceof Turret.TurretBuild && (settings.getBool("allTargetRange") || - !(player.unit().isFlying() && ((Turret)((Turret.TurretBuild) entityc).block).targetAir) || - !(player.unit().isFlying() && ((Turret)((Turret.TurretBuild) entityc).block).targetGround) || - !((Turret.TurretBuild) entityc).hasAmmo())))) { - Drawf.dashCircle(((Ranged) entityc).x(), ((Ranged) entityc).y(), ((Ranged) entityc).range(), Color.gray); - return; - }; - float range = ((Ranged) entityc).range(); - float margin = settings.getInt("rangeRadius") * tilesize; - if(Vars.player.dst((Position) entityc) <= range + margin) - Drawf.dashCircle(((Ranged) entityc).x(), ((Ranged) entityc).y(), range, ((Ranged) entityc).team().color); + (entityc instanceof BaseTurret.BaseTurretBuild || (settings.getBool("unitRange") && entityc instanceof Unit)), entityc -> { //only turret and unit are allowed + if(Vars.player.dst((Position) entityc) > ((Ranged) entityc).range() + settings.getInt("rangeRadius") * tilesize || //out of range is not allowed + (!settings.getBool("allTeamRange") && //derelict or player team are not allowed without setting + ((Ranged) entityc).team() == player.team() || ((Ranged) entityc).team() == Team.derelict)) return; + boolean h = false; + if(entityc instanceof Turret.TurretBuild){ + Turret turret = (Turret) ((Turret.TurretBuild)entityc).block; + if(((Turret.TurretBuild)entityc).hasAmmo()){ + if(player.unit().isGrounded() && turret.targetGround) h = true; + if(player.unit().isFlying() && turret.targetAir) h = true; + } + } + else if(entityc instanceof TractorBeamTurret.TractorBeamBuild){ + TractorBeamTurret turret = (TractorBeamTurret) ((TractorBeamTurret.TractorBeamBuild)entityc).block; + if(player.unit().isGrounded() && turret.targetGround) h = true; + if(player.unit().isFlying() && turret.targetAir) h = true; + } + else if(entityc instanceof ConstructBlock.ConstructBuild){ + if(((ConstructBlock.ConstructBuild)entityc).current instanceof Turret){ + Turret turret = (Turret) ((ConstructBlock.ConstructBuild)entityc).current; + if(player.unit().isGrounded() && turret.targetGround) h = true; + if(player.unit().isFlying() && turret.targetAir) h = true; + } + else if(((ConstructBlock.ConstructBuild)entityc).current instanceof TractorBeamTurret){ + TractorBeamTurret turret = (TractorBeamTurret) ((ConstructBlock.ConstructBuild)entityc).current; + if(player.unit().isGrounded() && turret.targetGround) h = true; + if(player.unit().isFlying() && turret.targetAir) h = true; + } + } + else if(entityc instanceof Unit){ + UnitType type = ((Unit) entityc).type; + if(player.unit().isGrounded() && type.targetGround) h = true; + if(player.unit().isFlying() && type.targetAir) h = true; + } + + if(h) Drawf.dashCircle(((Ranged) entityc).x(), ((Ranged) entityc).y(), ((Ranged) entityc).range(), ((Teamc) entityc).team().color); + else Drawf.dashCircle(((Ranged) entityc).x(), ((Ranged) entityc).y(), ((Ranged) entityc).range(), Color.gray); }); } });