diff --git a/core/src/mindustry/core/Renderer.java b/core/src/mindustry/core/Renderer.java index ec10061402..0e7855f3eb 100644 --- a/core/src/mindustry/core/Renderer.java +++ b/core/src/mindustry/core/Renderer.java @@ -201,6 +201,7 @@ public class Renderer implements ApplicationListener{ Draw.proj(camera); + blocks.checkChanges(); blocks.floor.checkChanges(); blocks.processBlocks(); diff --git a/core/src/mindustry/graphics/BlockRenderer.java b/core/src/mindustry/graphics/BlockRenderer.java index 5183551b93..032fe2709d 100644 --- a/core/src/mindustry/graphics/BlockRenderer.java +++ b/core/src/mindustry/graphics/BlockRenderer.java @@ -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); }); diff --git a/core/src/mindustry/graphics/FloorRenderer.java b/core/src/mindustry/graphics/FloorRenderer.java index 8d837b5dad..1e2247f71e 100644 --- a/core/src/mindustry/graphics/FloorRenderer.java +++ b/core/src/mindustry/graphics/FloorRenderer.java @@ -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