mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-19 03:03:59 +07:00
Environmental lights / Bugfixes
This commit is contained in:
parent
a9333baa78
commit
c15aec641a
@ -228,6 +228,10 @@ public class Blocks implements ContentList{
|
||||
attributes.set(Attribute.heat, 0.5f);
|
||||
attributes.set(Attribute.water, -0.2f);
|
||||
blendGroup = ignarock;
|
||||
|
||||
emitLight = true;
|
||||
lightRadius = 30f;
|
||||
lightColor = Color.orange.cpy().a(0.15f);
|
||||
}};
|
||||
|
||||
magmarock = new Floor("magmarock"){{
|
||||
@ -235,6 +239,10 @@ public class Blocks implements ContentList{
|
||||
attributes.set(Attribute.water, -0.5f);
|
||||
updateEffect = Fx.magmasmoke;
|
||||
blendGroup = ignarock;
|
||||
|
||||
emitLight = true;
|
||||
lightRadius = 60f;
|
||||
lightColor = Color.orange.cpy().a(0.3f);
|
||||
}};
|
||||
|
||||
sand = new Floor("sand"){{
|
||||
|
@ -534,7 +534,7 @@ public class UnitTypes implements ContentList{
|
||||
isCounted = false;
|
||||
|
||||
flying = true;
|
||||
mineSpeed = 12f;
|
||||
mineSpeed = 10f;
|
||||
mineTier = 1;
|
||||
buildSpeed = 0.5f;
|
||||
drag = 0.05f;
|
||||
|
@ -201,7 +201,7 @@ public class BlockRenderer implements Disposable{
|
||||
}
|
||||
|
||||
//lights are drawn even in the expanded range
|
||||
if(tile.build != null){
|
||||
if(tile.build != null || tile.block().emitLight){
|
||||
lightview.add(tile);
|
||||
}
|
||||
|
||||
@ -213,6 +213,11 @@ public class BlockRenderer implements Disposable{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//special case for floors
|
||||
if(block == Blocks.air && tile.floor().emitLight){
|
||||
lightview.add(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,15 +262,23 @@ public class BlockRenderer implements Disposable{
|
||||
}
|
||||
}
|
||||
|
||||
//draw lights
|
||||
for(int i = 0; i < lightview.size; i++){
|
||||
Tile tile = lightview.items[i];
|
||||
Building entity = tile.build;
|
||||
if(renderer.lights.enabled()){
|
||||
//draw lights
|
||||
for(int i = 0; i < lightview.size; i++){
|
||||
Tile tile = lightview.items[i];
|
||||
Building entity = tile.build;
|
||||
|
||||
if(entity != null){
|
||||
entity.drawLight();
|
||||
if(entity != null){
|
||||
entity.drawLight();
|
||||
}else if(tile.block().emitLight){
|
||||
tile.block().drawEnvironmentLight(tile);
|
||||
}else if(tile.floor().emitLight){
|
||||
tile.floor().drawEnvironmentLight(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,6 +26,10 @@ public class Drawf{
|
||||
return z;
|
||||
}
|
||||
|
||||
public static void light(float x, float y, float radius, Color color, float opacity){
|
||||
renderer.lights.add(x, y, radius, color, opacity);
|
||||
}
|
||||
|
||||
public static void light(Team team, float x, float y, float radius, Color color, float opacity){
|
||||
if(allowLight(team)) renderer.lights.add(x, y, radius, color, opacity);
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ public class LightRenderer{
|
||||
}
|
||||
|
||||
public boolean enabled(){
|
||||
return state.rules.lighting;
|
||||
return state.rules.lighting && state.rules.ambientLight.a > 0.00001f;
|
||||
}
|
||||
|
||||
public void draw(){
|
||||
|
@ -194,6 +194,9 @@ public class Styles{
|
||||
down = flatDown;
|
||||
up = none;
|
||||
over = flatOver;
|
||||
disabled = black8;
|
||||
imageDisabledColor = Color.lightGray;
|
||||
imageUpColor = Color.white;
|
||||
}};
|
||||
clearPartial2i = new ImageButtonStyle(){{
|
||||
down = whiteui;
|
||||
|
@ -146,6 +146,14 @@ public class Block extends UnlockableContent{
|
||||
public Sound breakSound = Sounds.boom;
|
||||
/** How reflective this block is. */
|
||||
public float albedo = 0f;
|
||||
/** Environmental passive light color. */
|
||||
public Color lightColor = Color.white.cpy();
|
||||
/**
|
||||
* Whether this environmental block passively emits light.
|
||||
* Not valid for non-environmental blocks. */
|
||||
public boolean emitLight = false;
|
||||
/** Radius of the light emitted by this block. */
|
||||
public float lightRadius = 60f;
|
||||
|
||||
/** The sound that this block makes while active. One sound loop. Do not overuse.*/
|
||||
public Sound activeSound = Sounds.none;
|
||||
@ -212,6 +220,10 @@ public class Block extends UnlockableContent{
|
||||
.sumf(other -> !other.floor().isLiquid ? 1f : 0f) / size / size;
|
||||
}
|
||||
|
||||
public void drawEnvironmentLight(Tile tile){
|
||||
Drawf.light(tile.worldx(), tile.worldy(), lightRadius, lightColor, lightColor.a);
|
||||
}
|
||||
|
||||
/** Drawn when you are placing a block. */
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user