mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 12:09:27 +02:00
better range shader
This commit is contained in:
@@ -766,7 +766,7 @@ public class HudUi {
|
||||
new Table(tt -> tt.button(Icon.downOpen, Styles.clearToggleTransi, () -> waveShown = !waveShown).size(4 * 8f).checked(b -> {
|
||||
b.getImage().setDrawable(waveShown ? Icon.upOpen : Icon.downOpen);
|
||||
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){
|
||||
@@ -890,6 +890,7 @@ public class HudUi {
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
public Element addBar(int i){
|
||||
return new Stack(){{
|
||||
add(new Table(t -> {
|
||||
@@ -936,6 +937,7 @@ public class HudUi {
|
||||
}));
|
||||
}};
|
||||
}
|
||||
|
||||
public void addBars(){
|
||||
bars.clear();
|
||||
for(int i = 0; i < 6; i++) bars.add(addBar(i));
|
||||
@@ -944,7 +946,7 @@ public class HudUi {
|
||||
public void addWeaponTable(Table table){
|
||||
table.table().update(tt -> {
|
||||
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++){
|
||||
Weapon weapon = u.type.weapons.get(r);
|
||||
WeaponMount mount = u.mounts[r];
|
||||
@@ -1302,7 +1304,7 @@ public class HudUi {
|
||||
public void addWaveTable(){
|
||||
if(uiIndex != 1) return;
|
||||
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 -> {
|
||||
ScrollPane pane = t.pane(new ScrollPane.ScrollPaneStyle(){{
|
||||
vScroll = Tex.clear;
|
||||
@@ -1354,7 +1356,7 @@ public class HudUi {
|
||||
public void addItemTable(){
|
||||
if(uiIndex != 2) return;
|
||||
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 -> {
|
||||
ScrollPane pane = t.pane(new ScrollPane.ScrollPaneStyle(){{
|
||||
vScroll = Tex.clear;
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
package UnitInfo.core;
|
||||
|
||||
import UnitInfo.shaders.LineShader;
|
||||
import UnitInfo.shaders.RangeShader;
|
||||
import UnitInfo.shaders.*;
|
||||
import arc.*;
|
||||
import arc.net.Server;
|
||||
import arc.util.Log;
|
||||
import mindustry.*;
|
||||
import mindustry.core.NetClient;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.Call;
|
||||
import mindustry.mod.*;
|
||||
|
||||
import static UnitInfo.SVars.*;
|
||||
|
||||
@@ -46,6 +46,8 @@ public class OverDrawer {
|
||||
public static FrameBuffer effectBuffer = new FrameBuffer();
|
||||
public static int otherCores;
|
||||
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(){
|
||||
Events.run(EventType.Trigger.draw, () -> {
|
||||
@@ -53,12 +55,12 @@ public class OverDrawer {
|
||||
|
||||
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.blit(lineShader);
|
||||
});
|
||||
|
||||
Draw.z(169);
|
||||
Draw.z(158);
|
||||
|
||||
int[] paths = {0};
|
||||
int[] units = {0};
|
||||
@@ -107,7 +109,7 @@ public class OverDrawer {
|
||||
if(paths[0] > settings.getInt("pathlinelimit")) return;
|
||||
paths[0]++;
|
||||
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);
|
||||
|
||||
getNextTile(t, p, enemyTeam, Pathfinder.fieldCore);
|
||||
@@ -139,6 +141,9 @@ public class OverDrawer {
|
||||
|
||||
if(Core.settings.getBool("unithealthui")) {
|
||||
Groups.unit.each(FreeBar::draw);
|
||||
}
|
||||
|
||||
if(Core.settings.getBool("blockfont")) {
|
||||
indexer.eachBlock(null, camera.position.x, camera.position.y, 400, b -> true, b -> {
|
||||
if(b instanceof ForceProjector.ForceBuild force) {
|
||||
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);
|
||||
}
|
||||
else Fonts.outline.draw((int)b.health + " / " + (int)b.maxHealth,
|
||||
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);
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
Draw.z(166);
|
||||
Unit unit = player.unit();
|
||||
Groups.build.each(e -> {
|
||||
if(!settings.getBool("allTeamRange") && e.team == player.team()) return; // Don't draw own turrets
|
||||
if(!(e instanceof BaseTurret.BaseTurretBuild)) return; // Not a turret
|
||||
if((e instanceof Turret.TurretBuild t && !t.hasAmmo()) || !e.cons.valid()) return; // No ammo
|
||||
tmpbuildobj.clear();
|
||||
for(int i = 0; i < Team.baseTeams.length; i++){
|
||||
int finalI = i;
|
||||
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 :
|
||||
e.block instanceof TractorBeamTurret tu && (unit.isFlying() ? tu.targetAir : tu.targetGround));
|
||||
float range = ((BaseTurret.BaseTurretBuild) e).range();
|
||||
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(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)));
|
||||
}
|
||||
});
|
||||
return ((finalI == 0 && (!canHit&&b.team!=Vars.player.team())) || (b.team == Team.baseTeams[finalI] && (b.team==Vars.player.team()||canHit))) &&
|
||||
((b instanceof Turret.TurretBuild t && t.hasAmmo()) || b.cons.valid()) &&
|
||||
(camera.position.dst(b) <= max || (control.input.block != null && dst <= max)) &&
|
||||
(canHit || settings.getBool("allTargetRange"));
|
||||
}));
|
||||
}
|
||||
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);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -107,21 +107,18 @@ public class SettingS {
|
||||
Seq<Seq<SharSetting>> settingSeq = new Seq<>();
|
||||
Seq<SharSetting> tapSeq = new Seq<>();
|
||||
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);
|
||||
addGraphicTypeSetting("wavemax", 0, 200,100, true, () -> true, s -> s + "waves", tapSeq);
|
||||
addGraphicCheckSetting("infoui", true, tapSeq);
|
||||
addGraphicCheckSetting("waveui", true, tapSeq);
|
||||
addGraphicCheckSetting("pastwave", false, tapSeq);
|
||||
addGraphicCheckSetting("emptywave", true, tapSeq);
|
||||
|
||||
Seq<SharSetting> rangeSeq = new Seq<>();
|
||||
addGraphicTypeSetting("rangeRadius", 0, 500, 70, true, () -> true, s -> s + "tiles", rangeSeq);
|
||||
addGraphicCheckSetting("rangeNearby", true, rangeSeq);
|
||||
addGraphicCheckSetting("allTeamRange", false, rangeSeq);
|
||||
addGraphicCheckSetting("allTargetRange", false, rangeSeq);
|
||||
addGraphicCheckSetting("coreRange", false, rangeSeq);
|
||||
addGraphicCheckSetting("unitRange", false, rangeSeq);
|
||||
addGraphicCheckSetting("RangeShader", true, rangeSeq);
|
||||
|
||||
Seq<SharSetting> opacitySeq = new Seq<>();
|
||||
@@ -137,12 +134,13 @@ public class SettingS {
|
||||
addGraphicTypeSetting("spawnarrowlimit", 0, 5000, 50, true, () -> true, s -> s + "arrows", drawSeq);
|
||||
addGraphicCheckSetting("gaycursor", false, drawSeq);
|
||||
addGraphicCheckSetting("unithealthui", true, drawSeq);
|
||||
addGraphicCheckSetting("blockfont", false, drawSeq);
|
||||
addGraphicCheckSetting("linkedMass", true, drawSeq);
|
||||
addGraphicCheckSetting("linkedNode", false, drawSeq);
|
||||
addGraphicCheckSetting("select", true, drawSeq);
|
||||
addGraphicCheckSetting("select", false, drawSeq);
|
||||
addGraphicCheckSetting("deadTarget", false, drawSeq);
|
||||
addGraphicCheckSetting("distanceLine", true, drawSeq);
|
||||
addGraphicCheckSetting("spawnerarrow", true, drawSeq);
|
||||
addGraphicCheckSetting("distanceLine", false, drawSeq);
|
||||
addGraphicCheckSetting("spawnerarrow", false, drawSeq);
|
||||
|
||||
Seq<SharSetting> etcSeq = new Seq<>();
|
||||
addGraphicCheckSetting("autoShooting", false, etcSeq);
|
||||
|
||||
Reference in New Issue
Block a user