New blocks

This commit is contained in:
Anuken
2019-01-27 23:26:07 -05:00
parent db2e6b6973
commit e9a82652a0
44 changed files with 1800 additions and 1838 deletions
@@ -100,18 +100,21 @@ public class BlockRenderer{
public void drawShadows(){
if(disableShadows) return;
Draw.color();
if(!Core.graphics.isHidden() && (shadows.getWidth() != Core.graphics.getWidth() || shadows.getHeight() != Core.graphics.getHeight())){
shadows.resize(Core.graphics.getWidth(), Core.graphics.getHeight());
}
Tmp.tr1.set(shadows.getTexture());
Shaders.outline.color.set(shadowColor);
Shaders.outline.scl = renderer.cameraScale()/3f;
Shaders.outline.region = Tmp.tr1;
Shaders.shadow.color.set(shadowColor);
Shaders.shadow.scl = renderer.cameraScale()/3f;
Shaders.shadow.region = Tmp.tr1;
Draw.flush();
shadows.begin();
Core.graphics.clear(Color.CLEAR);
floor.beginDraw();
floor.drawLayer(CacheLayer.walls);
floor.endDraw();
@@ -127,7 +130,7 @@ public class BlockRenderer{
Draw.flush();
shadows.end();
Draw.shader(Shaders.outline);
Draw.shader(Shaders.shadow);
Draw.rect(Draw.wrap(shadows.getTexture()),
camera.position.x,
camera.position.y,
@@ -188,10 +191,6 @@ public class BlockRenderer{
lastCamY = avgy;
lastRangeX = rangex;
lastRangeY = rangey;
floor.beginDraw();
floor.drawLayer(CacheLayer.walls);
floor.endDraw();
}
public void drawBlocks(Layer stopAt){
@@ -206,9 +205,7 @@ public class BlockRenderer{
Block block = req.tile.block();
if(req.layer == Layer.shadow){
Draw.color(0f, 0f, 0f, 0.45f);
block.drawShadow(req.tile);
Draw.color();
}else if(req.layer == Layer.block){
block.draw(req.tile);
if(block.synthetic() && req.tile.getTeam() != players[0].getTeam()){
@@ -12,6 +12,7 @@ import static io.anuke.mindustry.Vars.world;
public class Shaders{
public static Outline outline;
public static Shadow shadow;
public static BlockBuild blockbuild;
public static BlockPreview blockpreview;
public static Shield shield;
@@ -27,6 +28,7 @@ public class Shaders{
public static void init(){
outline = new Outline();
shadow = new Shadow();
blockbuild = new BlockBuild();
blockpreview = new BlockPreview();
shield = new Shield();
@@ -130,6 +132,23 @@ public class Shaders{
}
}
public static class Shadow extends LoadShader{
public Color color = new Color();
public TextureRegion region = new TextureRegion();
public float scl;
public Shadow(){
super("shadow", "default");
}
@Override
public void apply(){
setUniformf("u_color", color);
setUniformf("u_scl", scl);
setUniformf("u_texsize", region.getTexture().getWidth(), region.getTexture().getHeight());
}
}
public static class BlockBuild extends LoadShader{
public Color color = new Color();
public float progress;