mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 03:59:26 +02:00
shaddder
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
"description": "The mod displays more information in-game, such as unit/building, wave, core, tile, item/unit total info etc",
|
||||
"version": "1.4",
|
||||
"main": "UnitInfo.core.Main",
|
||||
"minGameVersion": "130.1",
|
||||
"minGameVersion": "131",
|
||||
"dependencies": [],
|
||||
"hidden": true,
|
||||
"java": true
|
||||
|
||||
24
assets/shaders/line.frag
Normal file
24
assets/shaders/line.frag
Normal file
@@ -0,0 +1,24 @@
|
||||
#define HIGHP
|
||||
|
||||
uniform sampler2D u_texture;
|
||||
uniform vec2 u_texsize;
|
||||
uniform vec2 u_invsize;
|
||||
uniform float u_time;
|
||||
uniform float u_dp;
|
||||
uniform vec2 u_offset;
|
||||
varying vec2 v_texCoords;
|
||||
|
||||
void main(){
|
||||
vec2 T = v_texCoords.xy;
|
||||
vec2 coords = (T * u_texsize) + u_offset;
|
||||
vec4 color = texture2D(u_texture, T);
|
||||
vec2 v = u_invsize;
|
||||
vec4 maxed = max(max(max(
|
||||
texture2D(u_texture, T + vec2(0, 2.0) * v),
|
||||
texture2D(u_texture, T + vec2(0, -2.0) * v)),
|
||||
texture2D(u_texture, T + vec2(2.0, 0) * v)),
|
||||
texture2D(u_texture, T + vec2(-2.0, 0) * v));
|
||||
|
||||
color.a *= (0.5 + abs(sin(u_time / 15.0)) * .05 + 0.2 * (step(mod(coords.x / u_dp + coords.y / u_dp + u_time / 4.0, 10.0), 3.0)));
|
||||
gl_FragColor = color;
|
||||
}
|
||||
28
assets/shaders/turretrange.frag
Normal file
28
assets/shaders/turretrange.frag
Normal file
@@ -0,0 +1,28 @@
|
||||
#define HIGHP
|
||||
|
||||
uniform sampler2D u_texture;
|
||||
uniform vec2 u_texsize;
|
||||
uniform vec2 u_invsize;
|
||||
uniform float u_time;
|
||||
uniform float u_dp;
|
||||
uniform vec2 u_offset;
|
||||
varying vec2 v_texCoords;
|
||||
|
||||
void main(){
|
||||
vec2 T = v_texCoords.xy;
|
||||
vec2 coords = (T * u_texsize) + u_offset;
|
||||
vec4 color = texture2D(u_texture, T);
|
||||
vec2 v = u_invsize;
|
||||
vec4 maxed = max(max(max(
|
||||
texture2D(u_texture, T + vec2(0, 2.0) * v),
|
||||
texture2D(u_texture, T + vec2(0, -2.0) * v)),
|
||||
texture2D(u_texture, T + vec2(2.0, 0) * v)),
|
||||
texture2D(u_texture, T + vec2(-2.0, 0) * v));
|
||||
|
||||
if(texture2D(u_texture, T).a < 0.9 && maxed.a > 0.9){
|
||||
gl_FragColor = vec4(maxed.rgb, maxed.a * 100.0);
|
||||
}else{
|
||||
color.a *= (0.37 + abs(sin(u_time / 15.0)) * .05 + 0.2 * (step(mod(coords.x / u_dp + coords.y / u_dp + u_time / 4.0, 10.0), 3.0)));
|
||||
gl_FragColor = color;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package UnitInfo;
|
||||
|
||||
import UnitInfo.core.*;
|
||||
import UnitInfo.shaders.LineShader;
|
||||
import UnitInfo.shaders.RangeShader;
|
||||
import arc.graphics.g2d.TextureRegion;
|
||||
|
||||
@@ -14,5 +15,6 @@ public class SVars {
|
||||
public static TextureRegion clear = atlas.find("clear");
|
||||
public static TextureRegion error = atlas.find("error");
|
||||
public static RangeShader turretRange;
|
||||
public static LineShader lineShader;
|
||||
public static boolean jsonGen = false;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ public class HudUi {
|
||||
ImageButton lockButton;
|
||||
boolean locked = false;
|
||||
|
||||
boolean waveShown;
|
||||
|
||||
float a;
|
||||
int uiIndex = 0;
|
||||
|
||||
@@ -291,7 +293,12 @@ public class HudUi {
|
||||
Table statusTable = Version.number >= 131 ? (Table)scene.find("statustable") : (Table)waveTable.getChildren().get(1);
|
||||
waveTable.removeChild(statusTable);
|
||||
table.row();
|
||||
table.stack(waveInfoTable, statusTable.top(), pathlineTable).fillX().colspan(table.getColumns());
|
||||
table.stack(
|
||||
new Table(tt -> tt.collapser(t -> t.stack(waveInfoTable, statusTable.top(), pathlineTable), true, () -> waveShown)).top(),
|
||||
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());
|
||||
}
|
||||
|
||||
public void reset(int index, Seq<Button> buttons, Label label, Table table, Table labelTable, String hud){
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package UnitInfo.core;
|
||||
|
||||
import UnitInfo.shaders.LineShader;
|
||||
import UnitInfo.shaders.RangeShader;
|
||||
import arc.*;
|
||||
import mindustry.*;
|
||||
@@ -14,6 +15,7 @@ public class Main extends Mod {
|
||||
@Override
|
||||
public void init(){
|
||||
turretRange = new RangeShader();
|
||||
lineShader = new LineShader();
|
||||
Core.app.post(() -> {
|
||||
Mods.ModMeta meta = Vars.mods.locateMod("unitinfo").meta;
|
||||
meta.displayName = "[#B5FFD9]Unit Information[]";
|
||||
|
||||
@@ -57,7 +57,13 @@ public class OverDrawer {
|
||||
effectBuffer.resize(graphics.getWidth(), graphics.getHeight());
|
||||
|
||||
float sin = Mathf.absin(Time.time, 6f, 1f);
|
||||
Draw.z(Layer.overlayUI);
|
||||
|
||||
Draw.drawRange(169, 1f, () -> effectBuffer.begin(Color.clear), () -> {
|
||||
effectBuffer.end();
|
||||
effectBuffer.blit(lineShader);
|
||||
});
|
||||
|
||||
Draw.z(169);
|
||||
|
||||
int[] paths = {0};
|
||||
int[] units = {0};
|
||||
@@ -122,6 +128,8 @@ public class OverDrawer {
|
||||
}
|
||||
});
|
||||
|
||||
Draw.z(Layer.overlayUI);
|
||||
|
||||
int[] arrows = {0};
|
||||
if(settings.getBool("spawnerarrow")) spawner.getSpawns().each(t -> {
|
||||
if(arrows[0] > settings.getInt("spawnarrowlimit")) return;
|
||||
@@ -261,21 +269,20 @@ public class OverDrawer {
|
||||
|
||||
if(settings.getBool("rangeNearby") && player != null && player.unit() != null && !player.unit().dead) {
|
||||
Draw.z(166);
|
||||
Team team = player.team();
|
||||
Unit unit = player.unit();
|
||||
Groups.build.each(e -> {
|
||||
if(!settings.getBool("allTeamRange") && e.team == team) return; // Don't draw own turrets
|
||||
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
|
||||
|
||||
boolean canHit = e.block instanceof Turret t ? unit.isFlying() ? t.targetAir : t.targetGround :
|
||||
e.block instanceof TractorBeamTurret tu && (unit.isFlying() ? tu.targetAir : tu.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(player.dst(e) <= max || (control.input.block != null && dst <= max)) {
|
||||
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));
|
||||
@@ -285,30 +292,30 @@ public class OverDrawer {
|
||||
Lines.line(e.x, e.y, e.x + Tmp.v1.x, e.y + Tmp.v1.y);
|
||||
}
|
||||
if(settings.getBool("RangeShader")) {
|
||||
Draw.color(Tmp.c1.set(canHit ? e.team.color : Team.derelict.color));
|
||||
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 : player.dst(e))/max), 0, settings.getInt("softRangeOpacity")/100f)));
|
||||
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") && player.unit() != null)) {
|
||||
if(settings.getBool("unitRange") || (settings.getBool("allTeamRange"))) {
|
||||
Groups.unit.each(u -> {
|
||||
if(!settings.getBool("unitRange") && settings.getBool("allTeamRange") && player.unit() != u) return; //player unit rule
|
||||
if(!settings.getBool("allTeamRange") && u.team == team) return; // Don't draw own units
|
||||
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.isFlying() ? u.type.targetAir : u.type.targetGround;
|
||||
boolean canHit = unit == null || (unit.isFlying() ? u.type.targetAir : u.type.targetGround);
|
||||
float range = u.range();
|
||||
float max = range + settings.getInt("rangeRadius") * tilesize;
|
||||
|
||||
if(Vars.player.dst(u) <= max && (canHit || settings.getBool("allTargetRange"))) { // Same as above
|
||||
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-Vars.player.dst(u)/max)));
|
||||
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)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class SettingS {
|
||||
addGraphicCheckSetting("emptywave", true, tapSeq);
|
||||
|
||||
Seq<SharSetting> rangeSeq = new Seq<>();
|
||||
addGraphicTypeSetting("rangeRadius", 0, 50, 20, true, () -> true, s -> s + "tiles", rangeSeq);
|
||||
addGraphicTypeSetting("rangeRadius", 0, 500, 20, true, () -> true, s -> s + "tiles", rangeSeq);
|
||||
addGraphicCheckSetting("rangeNearby", true, rangeSeq);
|
||||
addGraphicCheckSetting("allTeamRange", false, rangeSeq);
|
||||
addGraphicCheckSetting("allTargetRange", false, rangeSeq);
|
||||
|
||||
24
src/UnitInfo/shaders/LineShader.java
Normal file
24
src/UnitInfo/shaders/LineShader.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package UnitInfo.shaders;
|
||||
|
||||
import arc.Core;
|
||||
import arc.graphics.gl.Shader;
|
||||
import arc.scene.ui.layout.Scl;
|
||||
import arc.util.Time;
|
||||
import mindustry.Vars;
|
||||
|
||||
public class LineShader extends Shader {
|
||||
public LineShader() {
|
||||
super(Core.files.internal("shaders/screenspace.vert"), Vars.tree.get("shaders/line.frag"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
setUniformf("u_dp", Scl.scl(1f));
|
||||
setUniformf("u_time", Time.time / Scl.scl(1f));
|
||||
setUniformf("u_offset",
|
||||
Core.camera.position.x - Core.camera.width / 2,
|
||||
Core.camera.position.y - Core.camera.height / 2);
|
||||
setUniformf("u_texsize", Core.camera.width, Core.camera.height);
|
||||
setUniformf("u_invsize", 1f/Core.camera.width, 1f/Core.camera.height);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user