better range shader

This commit is contained in:
sharlottes
2021-10-18 15:59:06 +09:00
parent d879de937b
commit f5be756161
8 changed files with 56 additions and 89 deletions

View File

@@ -38,14 +38,10 @@ setting.rangeRadius.name = Near Range Margin
setting.rangeRadius.description = set the range detection distance. setting.rangeRadius.description = set the range detection distance.
setting.rangeNearby.name = Display Near Range setting.rangeNearby.name = Display Near Range
setting.rangeNearby.description = Enable automatic range display.\nIf you approach the range by a certain distance, the range is displayed in advance. setting.rangeNearby.description = Enable automatic range display.\nIf you approach the range by a certain distance, the range is displayed in advance.
setting.allTeamRange.name = Display Player Team Range
setting.allTeamRange.description = display alliance's range.
setting.allTargetRange.name = Display All Target Range setting.allTargetRange.name = Display All Target Range
setting.allTargetRange.description = display all range.\nThe range of targets that cannot be aimed at themselves is shown as gray. setting.allTargetRange.description = display all range.\nThe range of targets that cannot be aimed at themselves is shown as gray.
setting.coreRange.name = Display Core Range setting.coreRange.name = Display Core Range
setting.coreRange.description = display enemy core build-limit range. setting.coreRange.description = display enemy core build-limit range.
setting.unitRange.name = Display Unit Range
setting.unitRange.description = display unit range.
setting.RangeShader.name = Enable range animation setting.RangeShader.name = Enable range animation
setting.selectopacity.name = Select Arrow Opacity setting.selectopacity.name = Select Arrow Opacity

View File

@@ -26,8 +26,6 @@ setting.wavemax.name = 표시할 단계 수
setting.wavemax.description = 단계 탭에서 표시할 웨이브 수 제한을 설정합니다. setting.wavemax.description = 단계 탭에서 표시할 웨이브 수 제한을 설정합니다.
setting.infoui.name = 정보 UI 표시 setting.infoui.name = 정보 UI 표시
setting.infoui.description = 좌측 탭 UI를 표시합니다. 비활성 시 관련된 모든 업데이트가 중지됩니다. setting.infoui.description = 좌측 탭 UI를 표시합니다. 비활성 시 관련된 모든 업데이트가 중지됩니다.
setting.waveui.name = 단계 UI 표시
setting.waveui.description = 좌측 상단 UI를 포시합니다. 비활성 시 관련된 모든 업데이트가 중지됩니다.
setting.pastwave.name = 이전 단계 표시 setting.pastwave.name = 이전 단계 표시
setting.pastwave.description = 단계 탭에서 이전 단계를 표시합니다. 현재 단계는 빨간색으로 강조됩니다. setting.pastwave.description = 단계 탭에서 이전 단계를 표시합니다. 현재 단계는 빨간색으로 강조됩니다.
setting.emptywave.name = 빈 단계 표시 setting.emptywave.name = 빈 단계 표시
@@ -37,14 +35,10 @@ setting.rangeRadius.name = 사거리 접근 거리
setting.rangeRadius.description = 사거리 감지 거리를 설정합니다. setting.rangeRadius.description = 사거리 감지 거리를 설정합니다.
setting.rangeNearby.name = 자동 사거리 표시 setting.rangeNearby.name = 자동 사거리 표시
setting.rangeNearby.description = 자동 사거리 표시 기능을 활성화합니다. 적 사거리에 일정 거리만큼 접근하면 사거리를 미리 표시합니다. setting.rangeNearby.description = 자동 사거리 표시 기능을 활성화합니다. 적 사거리에 일정 거리만큼 접근하면 사거리를 미리 표시합니다.
setting.allTeamRange.name = 플레이어 팀 사거리 표시
setting.allTeamRange.description = 아군의 사거리를 표시합니다.
setting.allTargetRange.name = 모든 목표물 사거리 표시 setting.allTargetRange.name = 모든 목표물 사거리 표시
setting.allTargetRange.description = 모든 사거리를 표시합니다. 자신을 조준할 수 없는 대상의 사거리는 회색으로 보여집니다. setting.allTargetRange.description = 모든 사거리를 표시합니다. 자신을 조준할 수 없는 대상의 사거리는 회색으로 보여집니다.
setting.coreRange.name = 코어 사거리 표시 setting.coreRange.name = 코어 사거리 표시
setting.coreRange.description = 적 코어의 건설 제한 범위를 표시합니다. setting.coreRange.description = 적 코어의 건설 제한 범위를 표시합니다.
setting.unitRange.name = 유닛 사거리 표시
setting.unitRange.description = 유닛 사거리를 표시합니다.
setting.RangeShader.name = 사거리 에니매이션 활성화 setting.RangeShader.name = 사거리 에니매이션 활성화
setting.selectopacity.name = 선택 화살표 투명도 setting.selectopacity.name = 선택 화살표 투명도

View File

@@ -5,7 +5,7 @@
"description": "The mod displays more information in-game, such as unit/building, wave, core, tile, item/unit total info etc", "description": "The mod displays more information in-game, such as unit/building, wave, core, tile, item/unit total info etc",
"version": "1.5.1", "version": "1.5.1",
"main": "UnitInfo.core.Main", "main": "UnitInfo.core.Main",
"minGameVersion": "131", "minGameVersion": "133",
"dependencies": [], "dependencies": [],
"hidden": true, "hidden": true,
"java": true "java": true

View File

@@ -3,6 +3,6 @@ pArtifactFilename = UnitInfo.jar
# Group of project (should line up with dirs in src/) # Group of project (should line up with dirs in src/)
pGroup = sharlotte pGroup = sharlotte
# Version of Mindustry to use (if not working, consult jitpack.io) # Version of Mindustry to use (if not working, consult jitpack.io)
pMindustryVersion = v130.1 pMindustryVersion = v133
# Minimum API level for d8 (if you don't know what this is, leave it unless d8 yells at you) # Minimum API level for d8 (if you don't know what this is, leave it unless d8 yells at you)
pMinApi = 26 pMinApi = 26

View File

@@ -766,7 +766,7 @@ public class HudUi {
new Table(tt -> tt.button(Icon.downOpen, Styles.clearToggleTransi, () -> waveShown = !waveShown).size(4 * 8f).checked(b -> { new Table(tt -> tt.button(Icon.downOpen, Styles.clearToggleTransi, () -> waveShown = !waveShown).size(4 * 8f).checked(b -> {
b.getImage().setDrawable(waveShown ? Icon.upOpen : Icon.downOpen); b.getImage().setDrawable(waveShown ? Icon.upOpen : Icon.downOpen);
return waveShown; return waveShown;
})).left().top()).fillX().visible(() -> settings.getBool("waveui")); })).left().top()).fillX();
} }
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){
@@ -890,6 +890,7 @@ public class HudUi {
return region; return region;
} }
public Element addBar(int i){ public Element addBar(int i){
return new Stack(){{ return new Stack(){{
add(new Table(t -> { add(new Table(t -> {
@@ -936,6 +937,7 @@ public class HudUi {
})); }));
}}; }};
} }
public void addBars(){ public void addBars(){
bars.clear(); bars.clear();
for(int i = 0; i < 6; i++) bars.add(addBar(i)); for(int i = 0; i < 6; i++) bars.add(addBar(i));
@@ -944,7 +946,7 @@ public class HudUi {
public void addWeaponTable(Table table){ public void addWeaponTable(Table table){
table.table().update(tt -> { table.table().update(tt -> {
tt.clear(); tt.clear();
if(getTarget() instanceof Unit u && u.type != null) { if(getTarget() instanceof Unit u && u.type != null && u.hasWeapons()) {
for(int r = 0; r < u.type.weapons.size; r++){ for(int r = 0; r < u.type.weapons.size; r++){
Weapon weapon = u.type.weapons.get(r); Weapon weapon = u.type.weapons.get(r);
WeaponMount mount = u.mounts[r]; WeaponMount mount = u.mounts[r];
@@ -1302,7 +1304,7 @@ public class HudUi {
public void addWaveTable(){ public void addWaveTable(){
if(uiIndex != 1) return; if(uiIndex != 1) return;
waveTable = new Table(table -> { waveTable = new Table(table -> {
table.defaults().width(Scl.scl(modUiScale) * 35 * 8f).height(unitTable.getHeight() * Scl.scl(modUiScale)); table.defaults().width(Scl.scl(modUiScale) * 35 * 8f).height(35f * 8f * Scl.scl(modUiScale));
table.add(new Table(Tex.button, t -> { table.add(new Table(Tex.button, t -> {
ScrollPane pane = t.pane(new ScrollPane.ScrollPaneStyle(){{ ScrollPane pane = t.pane(new ScrollPane.ScrollPaneStyle(){{
vScroll = Tex.clear; vScroll = Tex.clear;
@@ -1354,7 +1356,7 @@ public class HudUi {
public void addItemTable(){ public void addItemTable(){
if(uiIndex != 2) return; if(uiIndex != 2) return;
itemTable = new Table(table -> { itemTable = new Table(table -> {
table.left().defaults().height(unitTable.getHeight() * Scl.scl(modUiScale)); table.left().defaults().height(35f * 8f * Scl.scl(modUiScale));
table.table(Tex.button, t -> { table.table(Tex.button, t -> {
ScrollPane pane = t.pane(new ScrollPane.ScrollPaneStyle(){{ ScrollPane pane = t.pane(new ScrollPane.ScrollPaneStyle(){{
vScroll = Tex.clear; vScroll = Tex.clear;

View File

@@ -1,14 +1,9 @@
package UnitInfo.core; package UnitInfo.core;
import UnitInfo.shaders.LineShader; import UnitInfo.shaders.*;
import UnitInfo.shaders.RangeShader;
import arc.*; import arc.*;
import arc.net.Server;
import arc.util.Log;
import mindustry.*; import mindustry.*;
import mindustry.core.NetClient;
import mindustry.game.EventType.*; import mindustry.game.EventType.*;
import mindustry.gen.Call;
import mindustry.mod.*; import mindustry.mod.*;
import static UnitInfo.SVars.*; import static UnitInfo.SVars.*;

View File

@@ -46,6 +46,8 @@ public class OverDrawer {
public static FrameBuffer effectBuffer = new FrameBuffer(); public static FrameBuffer effectBuffer = new FrameBuffer();
public static int otherCores; public static int otherCores;
public static boolean locked; public static boolean locked;
public static ObjectMap<Team, Seq<Building>> tmpbuildobj = new ObjectMap<>();
public static ObjectMap<Team, Seq<Unit>> tmpunitobj = new ObjectMap<>();
public static void setEvent(){ public static void setEvent(){
Events.run(EventType.Trigger.draw, () -> { Events.run(EventType.Trigger.draw, () -> {
@@ -53,12 +55,12 @@ public class OverDrawer {
float sin = Mathf.absin(Time.time, 6f, 1f); float sin = Mathf.absin(Time.time, 6f, 1f);
Draw.drawRange(169, 1f, () -> effectBuffer.begin(Color.clear), () -> { Draw.drawRange(158, 1f, () -> effectBuffer.begin(Color.clear), () -> {
effectBuffer.end(); effectBuffer.end();
effectBuffer.blit(lineShader); effectBuffer.blit(lineShader);
}); });
Draw.z(169); Draw.z(158);
int[] paths = {0}; int[] paths = {0};
int[] units = {0}; int[] units = {0};
@@ -107,7 +109,7 @@ public class OverDrawer {
if(paths[0] > settings.getInt("pathlinelimit")) return; if(paths[0] > settings.getInt("pathlinelimit")) return;
paths[0]++; paths[0]++;
Team enemyTeam = state.rules.waveTeam; Team enemyTeam = state.rules.waveTeam;
for(int p = 0; p < 3; p++) { for(int p = 0; p < (Vars.state.rules.spawns.count(g->g.type.naval)>0?3:2); p++) {
otherCores = Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != enemyTeam); otherCores = Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != enemyTeam);
getNextTile(t, p, enemyTeam, Pathfinder.fieldCore); getNextTile(t, p, enemyTeam, Pathfinder.fieldCore);
@@ -139,6 +141,9 @@ public class OverDrawer {
if(Core.settings.getBool("unithealthui")) { if(Core.settings.getBool("unithealthui")) {
Groups.unit.each(FreeBar::draw); Groups.unit.each(FreeBar::draw);
}
if(Core.settings.getBool("blockfont")) {
indexer.eachBlock(null, camera.position.x, camera.position.y, 400, b -> true, b -> { indexer.eachBlock(null, camera.position.x, camera.position.y, 400, b -> true, b -> {
if(b instanceof ForceProjector.ForceBuild force) { if(b instanceof ForceProjector.ForceBuild force) {
ForceProjector forceBlock = (ForceProjector) force.block; ForceProjector forceBlock = (ForceProjector) force.block;
@@ -165,8 +170,8 @@ public class OverDrawer {
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); 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, else Fonts.outline.draw((int)b.health + " / " + (int)b.maxHealth,
b.x, b.y - b.block.size * 8 * 0.25f, 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); 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);
}); });
} }
@@ -255,65 +260,42 @@ public class OverDrawer {
} }
} }
if(settings.getBool("RangeShader")) {
Draw.drawRange(166, 1f, () -> effectBuffer.begin(Color.clear), () -> {
effectBuffer.end();
effectBuffer.blit(turretRange);
});
}
if(settings.getBool("rangeNearby") && player != null && player.unit() != null && !player.unit().dead) { if(settings.getBool("rangeNearby") && player != null && player.unit() != null && !player.unit().dead) {
Draw.z(166);
Unit unit = player.unit(); Unit unit = player.unit();
Groups.build.each(e -> { tmpbuildobj.clear();
if(!settings.getBool("allTeamRange") && e.team == player.team()) return; // Don't draw own turrets for(int i = 0; i < Team.baseTeams.length; i++){
if(!(e instanceof BaseTurret.BaseTurretBuild)) return; // Not a turret int finalI = i;
if((e instanceof Turret.TurretBuild t && !t.hasAmmo()) || !e.cons.valid()) return; // No ammo tmpbuildobj.put(Team.baseTeams[i], Groups.build.copy(new Seq<Building>()).filter(b -> {
if(!(b instanceof BaseTurret.BaseTurretBuild)) return false;
boolean canHit = unit == null || (b.block instanceof Turret t ? unit.isFlying() ? t.targetAir : t.targetGround :
b.block instanceof TractorBeamTurret tu && (unit.isFlying() ? tu.targetAir : tu.targetGround));
float range = ((BaseTurret.BaseTurretBuild) b).range();
float max = range + settings.getInt("rangeRadius") * tilesize + b.block.offset;
float dst = Mathf.dst(control.input.getMouseX(), control.input.getMouseY(), b.x, b.y);
if(control.input.block != null && dst <= max) canHit = b.block instanceof Turret t && t.targetGround;
boolean canHit = unit == null || (e.block instanceof Turret t ? unit.isFlying() ? t.targetAir : t.targetGround : return ((finalI == 0 && (!canHit&&b.team!=Vars.player.team())) || (b.team == Team.baseTeams[finalI] && (b.team==Vars.player.team()||canHit))) &&
e.block instanceof TractorBeamTurret tu && (unit.isFlying() ? tu.targetAir : tu.targetGround)); ((b instanceof Turret.TurretBuild t && t.hasAmmo()) || b.cons.valid()) &&
float range = ((BaseTurret.BaseTurretBuild) e).range(); (camera.position.dst(b) <= max || (control.input.block != null && dst <= max)) &&
float max = range + settings.getInt("rangeRadius") * tilesize + e.block.offset; (canHit || settings.getBool("allTargetRange"));
float dst = Mathf.dst(control.input.getMouseX(), control.input.getMouseY(), e.x, e.y); }));
if(control.input.block != null && dst <= max) canHit = e.block instanceof Turret t && t.targetGround;
if(camera.position.dst(e) <= max || (control.input.block != null && dst <= max)) {
if(canHit || settings.getBool("allTargetRange")){
if(e instanceof Turret.TurretBuild t){
Lines.stroke(1.5f, Tmp.c1.set(canHit ? e.team.color : Team.derelict.color).a(0.75f));
Tmp.v1.set(e.x, e.y).trns(((BaseTurret.BaseTurretBuild)e).rotation+((Turret)t.block).shootCone, range);
Lines.line(e.x, e.y, e.x + Tmp.v1.x, e.y + Tmp.v1.y);
Tmp.v1.set(e.x, e.y).trns(((BaseTurret.BaseTurretBuild)e).rotation-((Turret)t.block).shootCone, range);
Lines.line(e.x, e.y, e.x + Tmp.v1.x, e.y + Tmp.v1.y);
}
if(settings.getBool("RangeShader")) {
Draw.color(Tmp.c1.a(1));
Fill.poly(e.x, e.y, Lines.circleVertices(range), range);
}
else 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 : camera.position.dst(e))/max), 0, settings.getInt("softRangeOpacity")/100f)));
}
}
});
// Unit Ranges (Only works when turret ranges are enabled)
if(settings.getBool("unitRange") || (settings.getBool("allTeamRange"))) {
Groups.unit.each(u -> {
if(!settings.getBool("unitRange") && settings.getBool("allTeamRange")) return; //player unit rule
if(!settings.getBool("allTeamRange") && u.team == player.team()) return; // Don't draw own units
if(u.controller() instanceof AIController ai && (ai instanceof BuilderAI || ai instanceof MinerAI)) return; //don't draw poly and mono
boolean canHit = unit == null || (unit.isFlying() ? u.type.targetAir : u.type.targetGround);
float range = u.range();
float max = range + settings.getInt("rangeRadius") * tilesize;
if(camera.position.dst(u) <= max && (canHit || settings.getBool("allTargetRange"))) { // Same as above
if(settings.getBool("RangeShader")) {
Draw.color(Tmp.c1.set(canHit ? u.team.color : Team.derelict.color));
Fill.poly(u.x, u.y, Lines.circleVertices(range), range);
}
else Fill.light(u.x, u.y, Lines.circleVertices(range), range, Color.clear, Tmp.c1.a(Math.min(settings.getInt("softRangeOpacity")/100f, 1.5f-camera.position.dst(u)/max)));
}
});
} }
tmpbuildobj.each((t, bseq) -> {
Draw.drawRange(166+t.id*3, 1, () -> effectBuffer.begin(Color.clear), () -> {
effectBuffer.end();
effectBuffer.blit(turretRange);
});
if(t==Team.derelict) Log.info(t.color);
Draw.color(t.color);
bseq.each(b -> {
float range = ((BaseTurret.BaseTurretBuild)b).range();
if(settings.getBool("RangeShader")) {
Draw.z(166+t.id*3);
Fill.poly(b.x, b.y, Lines.circleVertices(range), range);
}
else Lines.circle(b.x, b.y, range);
});
});
} }
}); });
} }

View File

@@ -107,21 +107,18 @@ public class SettingS {
Seq<Seq<SharSetting>> settingSeq = new Seq<>(); Seq<Seq<SharSetting>> settingSeq = new Seq<>();
Seq<SharSetting> tapSeq = new Seq<>(); Seq<SharSetting> tapSeq = new Seq<>();
addGraphicSlideSetting("barstyle", 0, 0, 5, 1, s -> s == 0 ? "default bar" : s + "th bar", tapSeq); addGraphicSlideSetting("barstyle", 0, 0, 5, 1, s -> s == 0 ? "default bar" : s + "th bar", tapSeq);
addGraphicSlideSetting("infoUiScale", mobile ? 50 : 75, 50, 100, 5, s -> s + "%", tapSeq); addGraphicSlideSetting("infoUiScale", mobile ? 25 : 50, 25, 100, 5, s -> s + "%", tapSeq);
addGraphicSlideSetting("coreItemCheckRate", 60, 6, 180, 6, s -> Strings.fixed(s/60f,1) + "sec", tapSeq); addGraphicSlideSetting("coreItemCheckRate", 60, 6, 180, 6, s -> Strings.fixed(s/60f,1) + "sec", tapSeq);
addGraphicTypeSetting("wavemax", 0, 200,100, true, () -> true, s -> s + "waves", tapSeq); addGraphicTypeSetting("wavemax", 0, 200,100, true, () -> true, s -> s + "waves", tapSeq);
addGraphicCheckSetting("infoui", true, tapSeq); addGraphicCheckSetting("infoui", true, tapSeq);
addGraphicCheckSetting("waveui", true, tapSeq);
addGraphicCheckSetting("pastwave", false, tapSeq); addGraphicCheckSetting("pastwave", false, tapSeq);
addGraphicCheckSetting("emptywave", true, tapSeq); addGraphicCheckSetting("emptywave", true, tapSeq);
Seq<SharSetting> rangeSeq = new Seq<>(); Seq<SharSetting> rangeSeq = new Seq<>();
addGraphicTypeSetting("rangeRadius", 0, 500, 70, true, () -> true, s -> s + "tiles", rangeSeq); addGraphicTypeSetting("rangeRadius", 0, 500, 70, true, () -> true, s -> s + "tiles", rangeSeq);
addGraphicCheckSetting("rangeNearby", true, rangeSeq); addGraphicCheckSetting("rangeNearby", true, rangeSeq);
addGraphicCheckSetting("allTeamRange", false, rangeSeq);
addGraphicCheckSetting("allTargetRange", false, rangeSeq); addGraphicCheckSetting("allTargetRange", false, rangeSeq);
addGraphicCheckSetting("coreRange", false, rangeSeq); addGraphicCheckSetting("coreRange", false, rangeSeq);
addGraphicCheckSetting("unitRange", false, rangeSeq);
addGraphicCheckSetting("RangeShader", true, rangeSeq); addGraphicCheckSetting("RangeShader", true, rangeSeq);
Seq<SharSetting> opacitySeq = new Seq<>(); Seq<SharSetting> opacitySeq = new Seq<>();
@@ -137,12 +134,13 @@ public class SettingS {
addGraphicTypeSetting("spawnarrowlimit", 0, 5000, 50, true, () -> true, s -> s + "arrows", drawSeq); addGraphicTypeSetting("spawnarrowlimit", 0, 5000, 50, true, () -> true, s -> s + "arrows", drawSeq);
addGraphicCheckSetting("gaycursor", false, drawSeq); addGraphicCheckSetting("gaycursor", false, drawSeq);
addGraphicCheckSetting("unithealthui", true, drawSeq); addGraphicCheckSetting("unithealthui", true, drawSeq);
addGraphicCheckSetting("blockfont", false, drawSeq);
addGraphicCheckSetting("linkedMass", true, drawSeq); addGraphicCheckSetting("linkedMass", true, drawSeq);
addGraphicCheckSetting("linkedNode", false, drawSeq); addGraphicCheckSetting("linkedNode", false, drawSeq);
addGraphicCheckSetting("select", true, drawSeq); addGraphicCheckSetting("select", false, drawSeq);
addGraphicCheckSetting("deadTarget", false, drawSeq); addGraphicCheckSetting("deadTarget", false, drawSeq);
addGraphicCheckSetting("distanceLine", true, drawSeq); addGraphicCheckSetting("distanceLine", false, drawSeq);
addGraphicCheckSetting("spawnerarrow", true, drawSeq); addGraphicCheckSetting("spawnerarrow", false, drawSeq);
Seq<SharSetting> etcSeq = new Seq<>(); Seq<SharSetting> etcSeq = new Seq<>();
addGraphicCheckSetting("autoShooting", false, etcSeq); addGraphicCheckSetting("autoShooting", false, etcSeq);