diff --git a/core/src/mindustry/entities/part/RegionPart.java b/core/src/mindustry/entities/part/RegionPart.java index 77094910b3..e2186f5e16 100644 --- a/core/src/mindustry/entities/part/RegionPart.java +++ b/core/src/mindustry/entities/part/RegionPart.java @@ -25,6 +25,8 @@ public class RegionPart extends DrawPart{ public boolean outline = true; /** If true, the base + outline regions are drawn. Set to false for heat-only regions. */ public boolean drawRegion = true; + /** If true, the heat region produces light. */ + public boolean heatLight = false; /** Progress function for determining position/rotation. */ public PartProgress progress = PartProgress.warmup; /** Progress function for heat alpha. */ @@ -34,6 +36,7 @@ public class RegionPart extends DrawPart{ public float outlineLayerOffset = -0.001f; public float x, y, rotation; public float moveX, moveY, moveRot; + public float heatLightOpacity = 0.3f; public @Nullable Color color, colorTo, mixColor, mixColorTo; public Color heatColor = Pal.turretHeat.cpy(); public Seq children = new Seq<>(); @@ -119,7 +122,10 @@ public class RegionPart extends DrawPart{ } if(heat.found()){ - Drawf.additive(heat, heatColor.write(Tmp.c1).a(heatProgress.getClamp(params) * heatColor.a), rx, ry, rot, turretShading ? turretHeatLayer : Draw.z() + heatLayerOffset); + float hprog = heatProgress.getClamp(params); + heatColor.write(Tmp.c1).a(hprog * heatColor.a); + Drawf.additive(heat, Tmp.c1, rx, ry, rot, turretShading ? turretHeatLayer : Draw.z() + heatLayerOffset); + if(heatLight) Drawf.light(rx, ry, heat, rot, Tmp.c1, heatLightOpacity * hprog); } Draw.xscl *= sign; diff --git a/core/src/mindustry/graphics/Drawf.java b/core/src/mindustry/graphics/Drawf.java index 95f78bcc44..0dbf5a5b33 100644 --- a/core/src/mindustry/graphics/Drawf.java +++ b/core/src/mindustry/graphics/Drawf.java @@ -241,8 +241,12 @@ public class Drawf{ } public static void light(float x, float y, TextureRegion region, Color color, float opacity){ + light(x, y, region, 0f, color, opacity); + } + + public static void light(float x, float y, TextureRegion region, float rotation, Color color, float opacity){ if(renderer == null) return; - renderer.lights.add(x, y, region, color, opacity); + renderer.lights.add(x, y, region, rotation, color, opacity); } public static void light(float x, float y, float x2, float y2){ diff --git a/core/src/mindustry/graphics/LightRenderer.java b/core/src/mindustry/graphics/LightRenderer.java index c28da979de..370586243b 100644 --- a/core/src/mindustry/graphics/LightRenderer.java +++ b/core/src/mindustry/graphics/LightRenderer.java @@ -42,15 +42,22 @@ public class LightRenderer{ circleIndex ++; } - + public void add(float x, float y, TextureRegion region, Color color, float opacity){ + add(x, y, region, 0f, color, opacity); + } + + public void add(float x, float y, TextureRegion region, float rotation, Color color, float opacity){ if(!enabled()) return; float res = color.toFloatBits(); + float xscl = Draw.xscl, yscl = Draw.yscl; add(() -> { Draw.color(res); Draw.alpha(opacity); - Draw.rect(region, x, y); + Draw.scl(xscl, yscl); + Draw.rect(region, x, y, rotation); + Draw.scl(); }); }