This commit is contained in:
Anuken
2020-04-23 00:41:18 -04:00
parent 18b68fefed
commit 2538273402
7 changed files with 61 additions and 33 deletions
+22 -13
View File
@@ -188,29 +188,38 @@ public class Renderer implements ApplicationListener{
Draw.proj(camera); Draw.proj(camera);
blocks.floor.checkChanges();
blocks.processBlocks();
Draw.sort(true); Draw.sort(true);
//beginFx(); //beginFx();
drawBackground(); Draw.draw(Layer.background, this::drawBackground);
Draw.draw(Layer.floor, blocks.floor::drawFloor);
Draw.draw(Layer.block - 1, blocks::drawShadows);
Draw.draw(Layer.block, () -> {
blocks.floor.beginDraw();
blocks.floor.drawLayer(CacheLayer.walls);
blocks.floor.endDraw();
});
blocks.floor.checkChanges(); if(state.rules.lighting){
blocks.floor.drawFloor(); Draw.draw(Layer.light, lights::draw);
}
//Groups.drawFloor(); if(state.rules.drawDarkness){
//Groups.drawFloorOver(); Draw.draw(Layer.darkness, blocks::drawDarkness);
}
blocks.processBlocks(); if(bloom != null){
blocks.drawShadows(); Draw.draw(Layer.bullet - 0.001f, bloom::capture);
Draw.color(); Draw.draw(Layer.effect + 0.001f, bloom::render);
}
blocks.floor.beginDraw();
blocks.floor.drawLayer(CacheLayer.walls);
blocks.floor.endDraw();
blocks.drawBlocks(); blocks.drawBlocks();
//draw stuff Groups.draw.draw(Drawc::draw);
Draw.reset(); Draw.reset();
Draw.flush(); Draw.flush();
@@ -13,6 +13,7 @@ import mindustry.core.*;
import mindustry.entities.units.*; import mindustry.entities.units.*;
import mindustry.game.*; import mindustry.game.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.net.Administration.*; import mindustry.net.Administration.*;
import mindustry.net.*; import mindustry.net.*;
import mindustry.net.Packets.*; import mindustry.net.Packets.*;
@@ -23,7 +24,7 @@ import static mindustry.Vars.*;
@EntityDef(value = {Playerc.class}, serialize = false) @EntityDef(value = {Playerc.class}, serialize = false)
@Component @Component
abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc{ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Drawc{
@NonNull @ReadOnly Unitc unit = Nulls.unit; @NonNull @ReadOnly Unitc unit = Nulls.unit;
@ReadOnly Team team = Team.sharded; @ReadOnly Team team = Team.sharded;
@@ -58,6 +59,12 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
} }
} }
@Override
public float clipSize(){
return 20;
}
@Override
public void update(){ public void update(){
if(unit.dead()){ if(unit.dead()){
clearUnit(); clearUnit();
@@ -130,7 +137,10 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
con.kick(reason); con.kick(reason);
} }
void drawName(){ @Override
public void draw(){
Draw.z(Layer.playerName);
BitmapFont font = Fonts.def; BitmapFont font = Fonts.def;
GlyphLayout layout = Pools.obtain(GlyphLayout.class, GlyphLayout::new); GlyphLayout layout = Pools.obtain(GlyphLayout.class, GlyphLayout::new);
final float nameHeight = 11; final float nameHeight = 11;
+1 -1
View File
@@ -81,7 +81,7 @@ public class Rules{
public boolean canGameOver = true; public boolean canGameOver = true;
/** Whether to draw shadows of blocks at map edges and static blocks. /** Whether to draw shadows of blocks at map edges and static blocks.
* Do not change unless you know exactly what you are doing.*/ * Do not change unless you know exactly what you are doing.*/
public boolean drawFog = true; public boolean drawDarkness = true;
/** Starting items put in cores */ /** Starting items put in cores */
public Array<ItemStack> loadout = Array.with(ItemStack.with(Items.copper, 100)); public Array<ItemStack> loadout = Array.with(ItemStack.with(Items.copper, 100));
/** Blocks that cannot be placed. */ /** Blocks that cannot be placed. */
@@ -26,7 +26,7 @@ public class BlockRenderer implements Disposable{
public final FloorRenderer floor = new FloorRenderer(); public final FloorRenderer floor = new FloorRenderer();
private Array<Tile> requests = new Array<>(initialRequests); private Array<Tile> requests = new Array<>(false, initialRequests, Tile.class);
private int lastCamX, lastCamY, lastRangeX, lastRangeY; private int lastCamX, lastCamY, lastRangeX, lastRangeY;
private float brokenFade = 0f; private float brokenFade = 0f;
@@ -94,7 +94,7 @@ public class BlockRenderer implements Disposable{
}); });
} }
public void drawFog(){ public void drawDarkness(){
float ww = world.width() * tilesize, wh = world.height() * tilesize; float ww = world.width() * tilesize, wh = world.height() * tilesize;
float x = camera.position.x + tilesize / 2f, y = camera.position.y + tilesize / 2f; float x = camera.position.x + tilesize / 2f, y = camera.position.y + tilesize / 2f;
float u = (x - camera.width / 2f) / ww, float u = (x - camera.width / 2f) / ww,
@@ -226,7 +226,10 @@ public class BlockRenderer implements Disposable{
Block block = tile.block(); Block block = tile.block();
Tilec entity = tile.entity; Tilec entity = tile.entity;
Draw.z(Layer.block);
block.drawBase(tile); block.drawBase(tile);
if(entity != null){ if(entity != null){
if(entity.damaged()){ if(entity.damaged()){
entity.drawCracks(); entity.drawCracks();
+3
View File
@@ -38,6 +38,9 @@ public class Layer{
//building plans //building plans
plans = 80, plans = 80,
//darkness over block clusters
darkness = 85,
//flying units //flying units
flyingUnit = 90, flyingUnit = 90,
@@ -102,24 +102,26 @@ public class BlockForge extends Block{
} }
if(recipe != null){ if(recipe != null){
TextureRegion region = recipe.icon(Cicon.full); Draw.draw(Layer.blockOver, () -> {
TextureRegion region = recipe.icon(Cicon.full);
Shaders.build.region = region; Shaders.build.region = region;
Shaders.build.progress = progress / recipe.buildCost; Shaders.build.progress = progress / recipe.buildCost;
Shaders.build.color.set(Pal.accent); Shaders.build.color.set(Pal.accent);
Shaders.build.color.a = heat; Shaders.build.color.a = heat;
Shaders.build.time = -time / 20f; Shaders.build.time = -time / 20f;
Draw.shader(Shaders.build); Draw.shader(Shaders.build);
Draw.rect(region, x, y); Draw.rect(region, x, y);
Draw.shader(); Draw.shader();
Draw.color(Pal.accent); Draw.color(Pal.accent);
Draw.alpha(heat); Draw.alpha(heat);
Lines.lineAngleCenter(x + Mathf.sin(time, 20f, Vars.tilesize / 2f * size - 2f), y, 90, size * Vars.tilesize - 4f); Lines.lineAngleCenter(x + Mathf.sin(time, 20f, Vars.tilesize / 2f * size - 2f), y, 90, size * Vars.tilesize - 4f);
Draw.reset(); Draw.reset();
});
} }
} }
@@ -197,8 +197,9 @@ public class CoreBlock extends StorageBlock{
super.draw(); super.draw();
if(heat > 0.001f){ if(heat > 0.001f){
Draw.z(Layer.blockOver); Draw.draw(Layer.blockOver, () -> {
Drawf.drawRespawn(this, heat, progress, time, unitType, lastRequested); Drawf.drawRespawn(this, heat, progress, time, unitType, lastRequested);
});
} }
} }