Allow heat region to produce light (#6879)
* Allow heat region to produce light * Method overload for backwards compatability
This commit is contained in:
@@ -25,6 +25,8 @@ public class RegionPart extends DrawPart{
|
|||||||
public boolean outline = true;
|
public boolean outline = true;
|
||||||
/** If true, the base + outline regions are drawn. Set to false for heat-only regions. */
|
/** If true, the base + outline regions are drawn. Set to false for heat-only regions. */
|
||||||
public boolean drawRegion = true;
|
public boolean drawRegion = true;
|
||||||
|
/** If true, the heat region produces light. */
|
||||||
|
public boolean heatLight = false;
|
||||||
/** Progress function for determining position/rotation. */
|
/** Progress function for determining position/rotation. */
|
||||||
public PartProgress progress = PartProgress.warmup;
|
public PartProgress progress = PartProgress.warmup;
|
||||||
/** Progress function for heat alpha. */
|
/** Progress function for heat alpha. */
|
||||||
@@ -34,6 +36,7 @@ public class RegionPart extends DrawPart{
|
|||||||
public float outlineLayerOffset = -0.001f;
|
public float outlineLayerOffset = -0.001f;
|
||||||
public float x, y, rotation;
|
public float x, y, rotation;
|
||||||
public float moveX, moveY, moveRot;
|
public float moveX, moveY, moveRot;
|
||||||
|
public float heatLightOpacity = 0.3f;
|
||||||
public @Nullable Color color, colorTo, mixColor, mixColorTo;
|
public @Nullable Color color, colorTo, mixColor, mixColorTo;
|
||||||
public Color heatColor = Pal.turretHeat.cpy();
|
public Color heatColor = Pal.turretHeat.cpy();
|
||||||
public Seq<DrawPart> children = new Seq<>();
|
public Seq<DrawPart> children = new Seq<>();
|
||||||
@@ -119,7 +122,10 @@ public class RegionPart extends DrawPart{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(heat.found()){
|
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;
|
Draw.xscl *= sign;
|
||||||
|
|||||||
@@ -241,8 +241,12 @@ public class Drawf{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void light(float x, float y, TextureRegion region, Color color, float opacity){
|
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;
|
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){
|
public static void light(float x, float y, float x2, float y2){
|
||||||
|
|||||||
@@ -42,15 +42,22 @@ public class LightRenderer{
|
|||||||
|
|
||||||
circleIndex ++;
|
circleIndex ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(float x, float y, TextureRegion region, Color color, float opacity){
|
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;
|
if(!enabled()) return;
|
||||||
|
|
||||||
float res = color.toFloatBits();
|
float res = color.toFloatBits();
|
||||||
|
float xscl = Draw.xscl, yscl = Draw.yscl;
|
||||||
add(() -> {
|
add(() -> {
|
||||||
Draw.color(res);
|
Draw.color(res);
|
||||||
Draw.alpha(opacity);
|
Draw.alpha(opacity);
|
||||||
Draw.rect(region, x, y);
|
Draw.scl(xscl, yscl);
|
||||||
|
Draw.rect(region, x, y, rotation);
|
||||||
|
Draw.scl();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user