Draws build request bridges using bridge opacity (#4180)

* Update ItemBridge.java

* Introduce renderer.bridgeOpacity
This commit is contained in:
Patrick 'Quezler' Mounier 2021-01-02 19:06:13 +01:00 committed by GitHub
parent bf81565e93
commit fe92ce557f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 9 deletions

View File

@ -29,7 +29,7 @@ public class Renderer implements ApplicationListener{
public @Nullable Bloom bloom;
public FrameBuffer effectBuffer = new FrameBuffer();
public float laserOpacity = 1f;
public float laserOpacity = 1f, bridgeOpacity = 1f;
public boolean animateShields, drawWeather = true;
/** minZoom = zooming out, maxZoom = zooming in */
public float minZoom = 1.5f, maxZoom = 6f;
@ -71,6 +71,7 @@ public class Renderer implements ApplicationListener{
camerascale = Mathf.lerpDelta(camerascale, dest, 0.1f);
if(Mathf.equal(camerascale, dest, 0.001f)) camerascale = dest;
laserOpacity = settings.getInt("lasersopacity") / 100f;
bridgeOpacity = settings.getInt("bridgeopacity") / 100f;
animateShields = settings.getBool("animatedshields");
if(landTime > 0){

View File

@ -36,9 +36,8 @@ public class ExtendingItemBridge extends ItemBridge{
ex *= uptime;
ey *= uptime;
float opacity = Core.settings.getInt("bridgeopacity") / 100f;
if(Mathf.zero(opacity)) return;
Draw.alpha(opacity);
if(Mathf.zero(renderer.bridgeOpacity)) return;
Draw.alpha(renderer.bridgeOpacity);
Lines.stroke(8f);
Lines.line(bridgeRegion,
@ -59,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 * opacity);
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

@ -70,6 +70,9 @@ 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);
Lines.stroke(8f);
Tmp.v1.set(ox, oy).sub(req.drawx(), req.drawy()).setLength(tilesize/2f);
@ -84,6 +87,8 @@ public class ItemBridge extends Block{
Draw.rect(arrowRegion, (req.drawx() + ox) / 2f, (req.drawy() + oy) / 2f,
Angles.angle(req.drawx(), req.drawy(), ox, oy) + flip);
Draw.reset();
}
@Override
@ -321,13 +326,12 @@ public class ItemBridge extends Block{
Tile other = world.tile(link);
if(!linkValid(tile, other)) return;
float opacity = Core.settings.getInt("bridgeopacity") / 100f;
if(Mathf.zero(opacity)) 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) * opacity);
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);
@ -350,7 +354,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 * opacity);
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);