This commit is contained in:
Anuken
2021-10-26 20:34:45 -04:00
parent 0242fd25e1
commit 705c85281c
9 changed files with 158 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ import mindustry.game.EventType.*;
import mindustry.game.Teams.*;
import mindustry.gen.*;
import mindustry.world.*;
import mindustry.world.blocks.environment.Floor.*;
import mindustry.world.blocks.power.*;
import static arc.Core.*;
@@ -30,6 +31,7 @@ public class BlockRenderer{
private Seq<Tile> tileview = new Seq<>(false, initialRequests, Tile.class);
private Seq<Tile> lightview = new Seq<>(false, initialRequests, Tile.class);
private Seq<UpdateRenderState> updateFloors = new Seq<>(UpdateRenderState.class);
private int lastCamX, lastCamY, lastRangeX, lastRangeY;
private float brokenFade = 0f;
@@ -78,6 +80,7 @@ public class BlockRenderer{
Draw.color();
shadows.end();
updateFloors.clear();
dark.getTexture().setFilter(TextureFilter.linear);
dark.resize(world.width(), world.height());
dark.begin();
@@ -87,6 +90,10 @@ public class BlockRenderer{
for(Tile tile : world.tiles){
recordIndex(tile);
if(tile.floor().updateRender(tile)){
updateFloors.add(new UpdateRenderState(tile, tile.floor()));
}
float darkness = world.getDarkness(tile.x, tile.y);
if(darkness > 0){
@@ -271,6 +278,16 @@ public class BlockRenderer{
int rangex = (int)(camera.width / tilesize / 2);
int rangey = (int)(camera.height / tilesize / 2);
if(!state.isPaused()){
int updates = updateFloors.size;
var uitems = updateFloors.items;
for(int i = 0; i < updates; i++){
var tile = uitems[i];
tile.floor.renderUpdate(tile);
}
}
if(avgx == lastCamX && avgy == lastCamY && lastRangeX == rangex && lastRangeY == rangey){
return;
}