This commit is contained in:
Anuken
2021-06-05 13:38:32 -04:00
parent b4dad32b2b
commit 9144f57b16
3 changed files with 12 additions and 5 deletions

View File

@@ -201,6 +201,7 @@ public class Renderer implements ApplicationListener{
Draw.proj(camera);
blocks.checkChanges();
blocks.floor.checkChanges();
blocks.processBlocks();

View File

@@ -13,7 +13,6 @@ import mindustry.content.*;
import mindustry.game.EventType.*;
import mindustry.game.Teams.*;
import mindustry.gen.*;
import mindustry.ui.*;
import mindustry.world.*;
import mindustry.world.blocks.power.*;
@@ -142,11 +141,21 @@ public class BlockRenderer{
Tile other = world.tile(cx, cy);
if(other != null){
darkEvents.add(other.pos());
floor.recacheTile(other);
}
}
}
}
public void checkChanges(){
darkEvents.each(pos -> {
var tile = world.tile(pos);
if(tile != null){
tile.data = world.getWallDarkness(tile);
}
});
}
public void drawDarkness(){
if(!darkEvents.isEmpty()){
Draw.flush();
@@ -156,10 +165,9 @@ public class BlockRenderer{
darkEvents.each(pos -> {
var tile = world.tile(pos);
tile.data = world.getWallDarkness(tile);
float darkness = world.getDarkness(tile.x, tile.y);
//then draw the shadow
Draw.colorl(!tile.isDarkened() || darkness <= 0f ? 1f : 1f - Math.min((darkness + 0.5f) / 4f, 1f));
Draw.colorl(darkness <= 0f ? 1f : 1f - Math.min((darkness + 0.5f) / 4f, 1f));
Fill.rect(tile.x + 0.5f, tile.y + 0.5f, 1, 1);
});

View File

@@ -97,7 +97,6 @@ public class FloorRenderer{
/** Queues up a cache change for a tile. Only runs in render loop. */
public void recacheTile(Tile tile){
//TODO will be faster it the position also specified the layer to be recached
//recaching all layers may not be necessary
recacheSet.add(Point2.pack(tile.x / chunksize, tile.y / chunksize));
}
@@ -168,7 +167,6 @@ public class FloorRenderer{
shader.setUniformi("u_texture", 0);
//only ever use the base environment texture
//TODO show error texture for anything else
texture.bind(0);
//enable all mesh attributes