Headless access of bridge/node opacity

This commit is contained in:
Anuken
2021-01-02 13:08:32 -05:00
parent fe92ce557f
commit 42ae5e90b0
4 changed files with 15 additions and 12 deletions

View File

@@ -20,6 +20,9 @@ import static arc.Core.*;
import static mindustry.Vars.*;
public class Renderer implements ApplicationListener{
/** These are global variables, for headless access. Cached. */
public static float laserOpacity = 0.5f, bridgeOpacity = 0.75f;
public final BlockRenderer blocks = new BlockRenderer();
public final MinimapRenderer minimap = new MinimapRenderer();
public final OverlayRenderer overlays = new OverlayRenderer();
@@ -29,7 +32,6 @@ public class Renderer implements ApplicationListener{
public @Nullable Bloom bloom;
public FrameBuffer effectBuffer = new FrameBuffer();
public float laserOpacity = 1f, bridgeOpacity = 1f;
public boolean animateShields, drawWeather = true;
/** minZoom = zooming out, maxZoom = zooming in */
public float minZoom = 1.5f, maxZoom = 6f;

View File

@@ -1,9 +1,9 @@
package mindustry.world.blocks.distribution;
import arc.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
import mindustry.core.*;
import mindustry.graphics.*;
import mindustry.world.*;
@@ -36,8 +36,8 @@ public class ExtendingItemBridge extends ItemBridge{
ex *= uptime;
ey *= uptime;
if(Mathf.zero(renderer.bridgeOpacity)) return;
Draw.alpha(renderer.bridgeOpacity);
if(Mathf.zero(Renderer.bridgeOpacity)) return;
Draw.alpha(Renderer.bridgeOpacity);
Lines.stroke(8f);
Lines.line(bridgeRegion,
@@ -58,7 +58,7 @@ public class ExtendingItemBridge extends ItemBridge{
Draw.color();
for(int a = 0; a < arrows; a++){
Draw.alpha(Mathf.absin(a / (float)arrows - time / 100f, 0.1f, 1f) * uptime * renderer.bridgeOpacity);
Draw.alpha(Mathf.absin(a / (float)arrows - time / 100f, 0.1f, 1f) * uptime * Renderer.bridgeOpacity);
Draw.rect(arrowRegion,
x + Geometry.d4(i).x * (tilesize / 2f + a * 6f + 2) * uptime,
y + Geometry.d4(i).y * (tilesize / 2f + a * 6f + 2) * uptime,

View File

@@ -10,6 +10,7 @@ import arc.struct.IntSet.*;
import arc.util.*;
import arc.util.io.*;
import mindustry.annotations.Annotations.*;
import mindustry.core.*;
import mindustry.entities.units.*;
import mindustry.gen.*;
import mindustry.graphics.*;
@@ -70,8 +71,8 @@ public class ItemBridge extends Block{
}
public void drawBridge(BuildPlan req, float ox, float oy, float flip){
if(Mathf.zero(renderer.bridgeOpacity)) return;
Draw.alpha(renderer.bridgeOpacity);
if(Mathf.zero(Renderer.bridgeOpacity)) return;
Draw.alpha(Renderer.bridgeOpacity);
Lines.stroke(8f);
@@ -326,12 +327,12 @@ public class ItemBridge extends Block{
Tile other = world.tile(link);
if(!linkValid(tile, other)) return;
if(Mathf.zero(renderer.bridgeOpacity)) return;
if(Mathf.zero(Renderer.bridgeOpacity)) return;
int i = relativeTo(other.x, other.y);
Draw.color(Color.white, Color.black, Mathf.absin(Time.time, 6f, 0.07f));
Draw.alpha(Math.max(uptime, 0.25f) * renderer.bridgeOpacity);
Draw.alpha(Math.max(uptime, 0.25f) * Renderer.bridgeOpacity);
Draw.rect(endRegion, x, y, i * 90 + 90);
Draw.rect(endRegion, other.drawx(), other.drawy(), i * 90 + 270);
@@ -354,7 +355,7 @@ public class ItemBridge extends Block{
Draw.color();
for(int a = 0; a < arrows; a++){
Draw.alpha(Mathf.absin(a / (float)arrows - time / 100f, 0.1f, 1f) * uptime * renderer.bridgeOpacity);
Draw.alpha(Mathf.absin(a / (float)arrows - time / 100f, 0.1f, 1f) * uptime * Renderer.bridgeOpacity);
Draw.rect(arrowRegion,
x + Geometry.d4(i).x * (tilesize / 2f + a * 4f + time % 4f),
y + Geometry.d4(i).y * (tilesize / 2f + a * 4f + time % 4f), i * 90f);

View File

@@ -159,7 +159,7 @@ public class PowerNode extends PowerBlock{
protected void setupColor(float satisfaction){
Draw.color(laserColor1, laserColor2, (1f - satisfaction) * 0.86f + Mathf.absin(3f, 0.1f));
Draw.alpha(renderer == null ? 0.5f : renderer.laserOpacity);
Draw.alpha(Renderer.laserOpacity);
}
protected void drawLaser(Team team, float x1, float y1, float x2, float y2, int size1, int size2){
@@ -391,7 +391,7 @@ public class PowerNode extends PowerBlock{
public void draw(){
super.draw();
if(Mathf.zero(renderer.laserOpacity)) return;
if(Mathf.zero(Renderer.laserOpacity)) return;
Draw.z(Layer.power);
setupColor(power.graph.getSatisfaction());