mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-25 22:58:47 +07:00
Block optimizations
This commit is contained in:
parent
33f5215e6d
commit
55e1759b47
@ -205,10 +205,8 @@ public class Blocks implements ContentList{
|
||||
variants = 1;
|
||||
}};
|
||||
|
||||
rocks = new Rock("rocks"){{
|
||||
rocks = new StaticWall("rocks"){{
|
||||
variants = 2;
|
||||
breakable = alwaysReplace = false;
|
||||
solid = true;
|
||||
}};
|
||||
|
||||
//endregion
|
||||
|
@ -73,6 +73,9 @@ public class BlockRenderer{
|
||||
shadows.begin();
|
||||
Core.graphics.clear(Color.CLEAR);
|
||||
Draw.color(shadowColor);
|
||||
floor.beginDraw();
|
||||
floor.drawLayer(CacheLayer.walls);
|
||||
floor.endDraw();
|
||||
drawBlocks(Layer.shadow);
|
||||
|
||||
EntityDraw.drawWith(playerGroup, player -> !player.isDead(), Unit::draw);
|
||||
@ -119,11 +122,11 @@ public class BlockRenderer{
|
||||
Tile tile = world.rawTile(x, y);
|
||||
Block block = tile.block();
|
||||
|
||||
if(!expanded && block != Blocks.air && world.isAccessible(x, y)){
|
||||
if(!expanded && block != Blocks.air && block.cacheLayer == CacheLayer.normal && world.isAccessible(x, y)){
|
||||
tile.block().drawShadow(tile);
|
||||
}
|
||||
|
||||
if(block != Blocks.air){
|
||||
if(block != Blocks.air && block.cacheLayer == CacheLayer.normal){
|
||||
if(!expanded){
|
||||
addRequest(tile, Layer.shadow);
|
||||
addRequest(tile, Layer.block);
|
||||
@ -148,6 +151,10 @@ public class BlockRenderer{
|
||||
lastCamY = avgy;
|
||||
lastRangeX = rangex;
|
||||
lastRangeY = rangey;
|
||||
|
||||
floor.beginDraw();
|
||||
floor.drawLayer(CacheLayer.walls);
|
||||
floor.endDraw();
|
||||
}
|
||||
|
||||
public void drawBlocks(Layer stopAt){
|
||||
|
@ -22,7 +22,8 @@ import io.anuke.mindustry.world.blocks.Floor;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class FloorRenderer{
|
||||
private final static int chunksize = 64;
|
||||
@ -156,7 +157,11 @@ public class FloorRenderer{
|
||||
Tile tile = world.tile(tilex, tiley);
|
||||
|
||||
if(tile != null){
|
||||
used.add(tile.floor().cacheLayer);
|
||||
if(tile.block().cacheLayer != CacheLayer.normal){
|
||||
used.add(tile.block().cacheLayer);
|
||||
}else{
|
||||
used.add(tile.floor().cacheLayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -183,7 +188,9 @@ public class FloorRenderer{
|
||||
floor = tile.floor();
|
||||
}
|
||||
|
||||
if(floor.cacheLayer == layer){
|
||||
if(tile.block().cacheLayer == layer && layer == CacheLayer.walls){
|
||||
tile.block().draw(tile);
|
||||
}else if(floor.cacheLayer == layer && tile.block().cacheLayer != CacheLayer.walls){
|
||||
floor.draw(tile);
|
||||
}
|
||||
}
|
||||
|
13
core/src/io/anuke/mindustry/world/blocks/StaticWall.java
Normal file
13
core/src/io/anuke/mindustry/world/blocks/StaticWall.java
Normal file
@ -0,0 +1,13 @@
|
||||
package io.anuke.mindustry.world.blocks;
|
||||
|
||||
import io.anuke.mindustry.graphics.CacheLayer;
|
||||
|
||||
public class StaticWall extends Rock{
|
||||
|
||||
public StaticWall(String name){
|
||||
super(name);
|
||||
breakable = alwaysReplace = false;
|
||||
solid = true;
|
||||
cacheLayer = CacheLayer.walls;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user