mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-13 19:39:04 +07:00
progress
This commit is contained in:
parent
d154361e75
commit
9beb23b0e4
@ -45,7 +45,7 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
|
||||
return (Float.isNaN(result) || Float.isInfinite(result)) ? 1f : Mathf.clamp(result, 0.0001f, 60f / 10f);
|
||||
});
|
||||
|
||||
batch = new SpriteBatch();
|
||||
batch = new SortedSpriteBatch();
|
||||
assets = new AssetManager();
|
||||
assets.setLoader(Texture.class, "." + mapExtension, new MapPreviewLoader());
|
||||
|
||||
|
@ -207,7 +207,9 @@ public class Renderer implements ApplicationListener{
|
||||
|
||||
Draw.sort(true);
|
||||
|
||||
blocks.drawBlocks();
|
||||
|
||||
//draw stuff
|
||||
|
||||
Draw.reset();
|
||||
Draw.flush();
|
||||
|
@ -25,11 +25,9 @@ public class BlockRenderer implements Disposable{
|
||||
|
||||
public final FloorRenderer floor = new FloorRenderer();
|
||||
|
||||
private Array<BlockRequest> requests = new Array<>(true, initialRequests, BlockRequest.class);
|
||||
private Array<Tile> requests = new Array<>(initialRequests);
|
||||
|
||||
private int lastCamX, lastCamY, lastRangeX, lastRangeY;
|
||||
private int requestidx = 0;
|
||||
private int iterateidx = 0;
|
||||
private float brokenFade = 0f;
|
||||
private FrameBuffer shadows = new FrameBuffer(2, 2);
|
||||
private FrameBuffer fog = new FrameBuffer(2, 2);
|
||||
@ -39,10 +37,6 @@ public class BlockRenderer implements Disposable{
|
||||
|
||||
public BlockRenderer(){
|
||||
|
||||
for(int i = 0; i < requests.size; i++){
|
||||
requests.set(i, new BlockRequest());
|
||||
}
|
||||
|
||||
Events.on(WorldLoadEvent.class, event -> {
|
||||
shadowEvents.clear();
|
||||
lastCamY = lastCamX = -99; //invalidate camera position so blocks get updated
|
||||
@ -179,7 +173,6 @@ public class BlockRenderer implements Disposable{
|
||||
/** Process all blocks to draw. */
|
||||
public void processBlocks(){
|
||||
displayStatus = Core.settings.getBool("blockstatus");
|
||||
iterateidx = 0;
|
||||
|
||||
int avgx = (int)(camera.position.x / tilesize);
|
||||
int avgy = (int)(camera.position.y / tilesize);
|
||||
@ -191,8 +184,6 @@ public class BlockRenderer implements Disposable{
|
||||
return;
|
||||
}
|
||||
|
||||
requestidx = 0;
|
||||
|
||||
int minx = Math.max(avgx - rangex - expandr, 0);
|
||||
int miny = Math.max(avgy - rangey - expandr, 0);
|
||||
int maxx = Math.min(world.width() - 1, avgx + rangex + expandr);
|
||||
@ -205,29 +196,14 @@ public class BlockRenderer implements Disposable{
|
||||
Block block = tile.block();
|
||||
|
||||
if(block != Blocks.air && tile.isCenter() && block.cacheLayer == CacheLayer.normal){
|
||||
if(!expanded){
|
||||
addRequest(tile, Layer.block);
|
||||
}
|
||||
|
||||
if(state.rules.lighting && tile.block().synthetic()){
|
||||
addRequest(tile, Layer.lights);
|
||||
}
|
||||
|
||||
if(block.expanded || !expanded){
|
||||
requests.add(tile);
|
||||
}
|
||||
|
||||
if(block.layer != null){
|
||||
addRequest(tile, block.layer);
|
||||
}
|
||||
|
||||
if(block.layer2 != null){
|
||||
addRequest(tile, block.layer2);
|
||||
}
|
||||
|
||||
if(tile.entity != null && tile.entity.power() != null && tile.entity.power().links.size > 0){
|
||||
for(Tilec other : tile.entity.getPowerConnections(outArray2)){
|
||||
if(other.block().layer == Layer.power){
|
||||
addRequest(other.tile(), Layer.power);
|
||||
}
|
||||
if(tile.entity != null && tile.entity.power() != null && tile.entity.power().links.size > 0){
|
||||
for(Tilec other : tile.entity.getPowerConnections(outArray2)){
|
||||
if(other.block().layer == Layer.power){
|
||||
requests.add(other.tile());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -235,14 +211,40 @@ public class BlockRenderer implements Disposable{
|
||||
}
|
||||
}
|
||||
|
||||
Sort.instance().sort(requests.items, 0, requestidx);
|
||||
|
||||
lastCamX = avgx;
|
||||
lastCamY = avgy;
|
||||
lastRangeX = rangex;
|
||||
lastRangeY = rangey;
|
||||
}
|
||||
|
||||
public void drawBlocks(){
|
||||
drawDestroyed();
|
||||
|
||||
for(int i = 0; i < requests.size; i++){
|
||||
Tile tile = requests.items[i];
|
||||
Block block = tile.block();
|
||||
Tilec entity = tile.entity;
|
||||
|
||||
block.drawBase(tile);
|
||||
if(entity != null){
|
||||
if(entity.damaged()){
|
||||
entity.drawCracks();
|
||||
}
|
||||
|
||||
if(entity.team() != player.team()){
|
||||
entity.drawTeam();
|
||||
}
|
||||
|
||||
entity.drawLight();
|
||||
|
||||
if(displayStatus && block.consumes.any()){
|
||||
entity.drawStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public void drawBlocks(Layer stopAt){
|
||||
int startIdx = iterateidx;
|
||||
for(; iterateidx < requestidx; iterateidx++){
|
||||
@ -295,7 +297,7 @@ public class BlockRenderer implements Disposable{
|
||||
r.tile = tile;
|
||||
r.layer = layer;
|
||||
requestidx++;
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void dispose(){
|
||||
@ -304,21 +306,4 @@ public class BlockRenderer implements Disposable{
|
||||
shadows = fog = null;
|
||||
floor.dispose();
|
||||
}
|
||||
|
||||
private class BlockRequest implements Comparable<BlockRequest>{
|
||||
Tile tile;
|
||||
Layer layer;
|
||||
|
||||
@Override
|
||||
public int compareTo(BlockRequest other){
|
||||
int compare = layer.compareTo(other.layer);
|
||||
|
||||
return (compare != 0) ? compare : Integer.compare(tile.pos(), other.tile.pos());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return tile.block().name + ":" + layer.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=5796def2ff3d03c280655ebf60b98aaf66de5422
|
||||
archash=87ff7abf2af82712cc428c377833d83259d30f72
|
||||
|
Loading…
Reference in New Issue
Block a user