Fixed some tiled floor/wall bugs
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user