Configurable ambient light, darkness
This commit is contained in:
@@ -300,7 +300,9 @@ public class Renderer implements ApplicationListener{
|
||||
|
||||
playerGroup.draw(p -> !p.isDead(), Player::drawName);
|
||||
|
||||
lights.draw();
|
||||
if(state.rules.darkness){
|
||||
lights.draw();
|
||||
}
|
||||
|
||||
drawLanding();
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.game;
|
||||
|
||||
import io.anuke.annotations.Annotations.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
@@ -73,6 +74,10 @@ public class Rules{
|
||||
public Array<ItemStack> loadout = Array.with(ItemStack.with(Items.copper, 100));
|
||||
/** Blocks that cannot be placed. */
|
||||
public ObjectSet<Block> bannedBlocks = new ObjectSet<>();
|
||||
/** Whether everything is dark. Enables lights. Exeperimental. */
|
||||
public boolean darkness = true;
|
||||
/** Ambient light color, used when darkness is enabled. */
|
||||
public Color ambientLight = new Color(0.01f, 0.01f, 0.04f, 0.99f);
|
||||
|
||||
/** Copies this ruleset exactly. Not very efficient at all, do not use often. */
|
||||
public Rules copy(){
|
||||
|
||||
@@ -9,6 +9,9 @@ import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
|
||||
/** Renders overlay lights. Client only. */
|
||||
public class LightRenderer{
|
||||
private static final int scaling = 4;
|
||||
private float[] vertices = new float[24];
|
||||
@@ -16,10 +19,14 @@ public class LightRenderer{
|
||||
private Array<Runnable> lights = new Array<>();
|
||||
|
||||
public void add(Runnable run){
|
||||
if(!enabled()) return;
|
||||
|
||||
lights.add(run);
|
||||
}
|
||||
|
||||
public void add(float x, float y, float radius, Color color, float opacity){
|
||||
if(!enabled()) return;
|
||||
|
||||
float res = color.toFloatBits();
|
||||
add(() -> {
|
||||
Draw.color(res);
|
||||
@@ -29,6 +36,8 @@ public class LightRenderer{
|
||||
}
|
||||
|
||||
public void add(float x, float y, TextureRegion region, Color color, float opacity){
|
||||
if(!enabled()) return;
|
||||
|
||||
float res = color.toFloatBits();
|
||||
add(() -> {
|
||||
Draw.color(res);
|
||||
@@ -38,6 +47,8 @@ public class LightRenderer{
|
||||
}
|
||||
|
||||
public void line(float x, float y, float x2, float y2){
|
||||
if(!enabled()) return;
|
||||
|
||||
add(() -> {
|
||||
Draw.color(Color.orange, 0.5f);
|
||||
|
||||
@@ -158,6 +169,10 @@ public class LightRenderer{
|
||||
});
|
||||
}
|
||||
|
||||
public boolean enabled(){
|
||||
return state.rules.darkness;
|
||||
}
|
||||
|
||||
public void draw(){
|
||||
if(buffer.getWidth() != Core.graphics.getWidth()/scaling || buffer.getHeight() != Core.graphics.getHeight()/scaling){
|
||||
buffer.resize(Core.graphics.getWidth()/scaling, Core.graphics.getHeight()/scaling);
|
||||
@@ -174,6 +189,7 @@ public class LightRenderer{
|
||||
buffer.endDraw();
|
||||
|
||||
Draw.color();
|
||||
Shaders.light.ambient.set(state.rules.ambientLight);
|
||||
Draw.shader(Shaders.light);
|
||||
Draw.rect(Draw.wrap(buffer.getTexture()), Core.camera.position.x, Core.camera.position.y, Core.camera.width, -Core.camera.height);
|
||||
Draw.shader();
|
||||
|
||||
@@ -27,7 +27,7 @@ public class NuclearReactor extends PowerGenerator{
|
||||
|
||||
protected final Vector2 tr = new Vector2();
|
||||
|
||||
protected Color lightColor = Color.valueOf("b174f1");
|
||||
protected Color lightColor = Color.valueOf("7f19ea");
|
||||
protected Color coolColor = new Color(1, 1, 1, 0f);
|
||||
protected Color hotColor = Color.valueOf("ff9575a3");
|
||||
protected float itemDuration = 120; //time to consume 1 fuel
|
||||
|
||||
Reference in New Issue
Block a user