From d6619b90553ccd904db3e364006e18f10c84edf1 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 31 Dec 2025 11:15:29 -0500 Subject: [PATCH] Fixed some tiled floor/wall bugs --- .../src/mindustry/graphics/FloorRenderer.java | 39 ++++++++++--------- core/src/mindustry/world/Tile.java | 2 +- .../world/blocks/environment/TiledFloor.java | 11 +++--- .../world/blocks/environment/TiledWall.java | 7 ++-- 4 files changed, 32 insertions(+), 27 deletions(-) diff --git a/core/src/mindustry/graphics/FloorRenderer.java b/core/src/mindustry/graphics/FloorRenderer.java index 65c6114f55..0873c62fd4 100644 --- a/core/src/mindustry/graphics/FloorRenderer.java +++ b/core/src/mindustry/graphics/FloorRenderer.java @@ -322,31 +322,34 @@ public class FloorRenderer{ vidx = 0; Batch current = Core.batch; - Core.batch = batch; - for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize; tilex++){ - for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize; tiley++){ - Tile tile = world.tile(tilex, tiley); - Floor floor; + try{ + Core.batch = batch; - if(tile == null){ - continue; - }else{ - floor = tile.floor(); - } + for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize; tilex++){ + for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize; tiley++){ + Tile tile = world.tile(tilex, tiley); + Floor floor; - if(tile.block().cacheLayer == layer && layer == CacheLayer.walls && !(tile.isDarkened() && tile.data >= 5)){ - tile.block().drawBase(tile); - }else if(floor.cacheLayer == layer && (ignoreWalls || world.isAccessible(tile.x, tile.y) || tile.block().cacheLayer != CacheLayer.walls || !tile.block().fillsTile)){ - floor.drawBase(tile); - }else if(floor.cacheLayer != layer && layer != CacheLayer.walls){ - floor.drawNonLayer(tile, layer); + if(tile == null){ + continue; + }else{ + floor = tile.floor(); + } + + if(tile.block().cacheLayer == layer && layer == CacheLayer.walls && !(tile.isDarkened() && tile.data >= 5)){ + tile.block().drawBase(tile); + }else if(floor.cacheLayer == layer && (ignoreWalls || world.isAccessible(tile.x, tile.y) || tile.block().cacheLayer != CacheLayer.walls || !tile.block().fillsTile)){ + floor.drawBase(tile); + }else if(floor.cacheLayer != layer && layer != CacheLayer.walls){ + floor.drawNonLayer(tile, layer); + } } } + }finally{ + Core.batch = current; } - Core.batch = current; - int floats = vidx; ChunkMesh mesh = new ChunkMesh(true, floats / vertexSize, 0, attributes, cx * tilesize * chunksize - tilesize/2f, cy * tilesize * chunksize - tilesize/2f, diff --git a/core/src/mindustry/world/Tile.java b/core/src/mindustry/world/Tile.java index 2ab4a4ab73..eb17c663fb 100644 --- a/core/src/mindustry/world/Tile.java +++ b/core/src/mindustry/world/Tile.java @@ -452,7 +452,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{ /** @return whether the floor on this tile deals damage or can be drowned on. */ public boolean dangerous(){ - return !block.solid && (floor.isDeep() || floor.damageTaken > 0); + return !block.solid && (floor.isDeep() || floor.damages()); } /** diff --git a/core/src/mindustry/world/blocks/environment/TiledFloor.java b/core/src/mindustry/world/blocks/environment/TiledFloor.java index 85ff8603c1..5e258dddf0 100644 --- a/core/src/mindustry/world/blocks/environment/TiledFloor.java +++ b/core/src/mindustry/world/blocks/environment/TiledFloor.java @@ -9,6 +9,7 @@ import mindustry.world.*; import static mindustry.Vars.*; +/** Renders floors in packed square tiles, sized to be as large as possible given the provided size constraints. Concept and some code taken from Twcash/Aquarion. */ public class TiledFloor extends Floor{ public TextureRegion[][][][] sizedRegions; public int maxSize = 3; @@ -27,10 +28,10 @@ public class TiledFloor extends Floor{ public void load(){ super.load(); - sizedRegions = new TextureRegion[maxSize + 1][variants][][]; + sizedRegions = new TextureRegion[maxSize + 1][Math.max(variants, 1)][][]; for(int size = 1; size <= maxSize; size++){ - for(int v = 0; v < variants; v++){ + for(int v = 0; v < Math.max(variants, 1); v++){ TextureRegion base = Core.atlas.find(name + "-" + size + "-" + v); int actualSize = size; if(!base.found()) base = Core.atlas.find(name + "-" + size); @@ -51,7 +52,7 @@ public class TiledFloor extends Floor{ @Override public void floorChanged(Tile tile){ - if(TiledState.changes(state(tile)) != world.floorChanges && !world.isGenerating()){ + if(!world.isGenerating() && TiledState.changes(state(tile)) != world.floorChanges){ scan(tile); } } @@ -60,13 +61,13 @@ public class TiledFloor extends Floor{ //max size possible int size = maxSize; int changes = world.floorChanges; - boolean isOverlay = tile.floor() != this; + boolean isOverlay = tile.overlay() == this; //scan to the top right for the biggest size possible for(int cx = 0; cx < size; cx++){ for(int cy = 0; cy < size; cy++){ Tile other = tile.nearby(cx, cy); - if(other == null || ((isOverlay ? other.overlay() : other.floor()) != this) || TiledState.changes(state(other)) == changes){ + if(other == null || (isOverlay ? other.overlay() : other.floor()) != this || TiledState.changes(state(other)) == changes){ int max = Math.max(cx, cy); size = Math.min(max, size); size = Math.min(max, size); diff --git a/core/src/mindustry/world/blocks/environment/TiledWall.java b/core/src/mindustry/world/blocks/environment/TiledWall.java index 1286add73c..c3c0103e42 100644 --- a/core/src/mindustry/world/blocks/environment/TiledWall.java +++ b/core/src/mindustry/world/blocks/environment/TiledWall.java @@ -8,6 +8,7 @@ import mindustry.world.*; import static mindustry.Vars.*; +/** Renders walls in packed square tiles, sized to be as large as possible given the provided size constraints. Concept and some code taken from Twcash/Aquarion. */ public class TiledWall extends StaticWall{ public TextureRegion[][][][] sizedRegions; public int maxSize = 3; @@ -26,10 +27,10 @@ public class TiledWall extends StaticWall{ public void load(){ super.load(); - sizedRegions = new TextureRegion[maxSize + 1][variants][][]; + sizedRegions = new TextureRegion[maxSize + 1][Math.max(variants, 1)][][]; for(int size = 1; size <= maxSize; size++){ - for(int v = 0; v < variants; v++){ + for(int v = 0; v < Math.max(variants, 1); v++){ TextureRegion base = Core.atlas.find(name + "-" + size + "-" + v); int actualSize = size; if(!base.found()) base = Core.atlas.find(name + "-" + size); @@ -51,7 +52,7 @@ public class TiledWall extends StaticWall{ public void blockChanged(Tile tile){ super.blockChanged(tile); - if(TiledState.changes(state(tile)) != world.tileChanges && !world.isGenerating()){ + if(!world.isGenerating() && TiledState.changes(state(tile)) != world.tileChanges){ scan(tile); } }