Allow heat region to produce light (#6879)

* Allow heat region to produce light

* Method overload for backwards compatability
This commit is contained in:
MEEPofFaith
2022-11-06 11:28:59 -08:00
committed by GitHub
parent 83be0116c6
commit 810a905af3
3 changed files with 21 additions and 4 deletions

View File

@@ -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<DrawPart> 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;

View File

@@ -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){

View File

@@ -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();
});
}