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