Removed unused shadow methods; minor tweaks

This commit is contained in:
Anuken
2019-03-29 09:07:46 -04:00
parent 532c36677c
commit 27e9901d05
7 changed files with 12 additions and 30 deletions
@@ -87,6 +87,7 @@ public class Blocks implements ContentList{
air = new Floor("air"){{ air = new Floor("air"){{
alwaysReplace = true; alwaysReplace = true;
hasShadow = false;
} }
public void draw(Tile tile){} public void draw(Tile tile){}
@@ -735,6 +736,7 @@ public class Blocks implements ContentList{
shockMine = new ShockMine("shock-mine"){{ shockMine = new ShockMine("shock-mine"){{
requirements(Category.effect, ItemStack.with(Items.lead, 50, Items.silicon, 25)); requirements(Category.effect, ItemStack.with(Items.lead, 50, Items.silicon, 25));
hasShadow = false;
health = 40; health = 40;
damage = 11; damage = 11;
tileDamage = 7f; tileDamage = 7f;
@@ -1096,7 +1098,7 @@ public class Blocks implements ContentList{
}}; }};
unloader = new Unloader("unloader"){{ unloader = new Unloader("unloader"){{
requirements(Category.distribution, ItemStack.with(Items.titanium, 50, Items.silicon, 60)); requirements(Category.effect, ItemStack.with(Items.titanium, 50, Items.silicon, 60));
speed = 7f; speed = 7f;
}}; }};
@@ -57,7 +57,7 @@ public class BlockRenderer{
for(int x = 0; x < world.width(); x++){ for(int x = 0; x < world.width(); x++){
for(int y = 0; y < world.height(); y++){ for(int y = 0; y < world.height(); y++){
Tile tile = world.rawTile(x, y); Tile tile = world.rawTile(x, y);
if(tile.block() != Blocks.air){ if(tile.block().hasShadow){
Fill.rect(tile.x + 0.5f, tile.y + 0.5f, 1, 1); Fill.rect(tile.x + 0.5f, tile.y + 0.5f, 1, 1);
} }
} }
@@ -125,7 +125,11 @@ public class BlockRenderer{
Draw.proj().setOrtho(0, 0, shadows.getWidth(), shadows.getHeight()); Draw.proj().setOrtho(0, 0, shadows.getWidth(), shadows.getHeight());
for(Tile tile : shadowEvents){ for(Tile tile : shadowEvents){
Draw.color(tile.block() == Blocks.air ? Color.WHITE : shadowColor); //clear it first
Draw.color(Color.WHITE);
Fill.rect(tile.x + 0.5f, tile.y + 0.5f, 1, 1);
//then draw the shadow
Draw.color(!tile.block().hasShadow ? Color.WHITE : shadowColor);
Fill.rect(tile.x + 0.5f, tile.y + 0.5f, 1, 1); Fill.rect(tile.x + 0.5f, tile.y + 0.5f, 1, 1);
} }
@@ -186,7 +190,6 @@ public class BlockRenderer{
} }
if(block.expanded || !expanded){ if(block.expanded || !expanded){
addRequest(tile, Layer.shadow);
if(block.layer != null && block.isLayer(tile)){ if(block.layer != null && block.isLayer(tile)){
addRequest(tile, block.layer); addRequest(tile, block.layer);
@@ -227,9 +230,7 @@ public class BlockRenderer{
BlockRequest req = requests.get(iterateidx); BlockRequest req = requests.get(iterateidx);
Block block = req.tile.block(); Block block = req.tile.block();
if(req.layer == Layer.shadow){ if(req.layer == Layer.block){
block.drawShadow(req.tile);
}else if(req.layer == Layer.block){
block.draw(req.tile); block.draw(req.tile);
if(block.synthetic() && req.tile.getTeam() != player.getTeam()){ if(block.synthetic() && req.tile.getTeam() != player.getTeam()){
block.drawTeam(req.tile); block.drawTeam(req.tile);
@@ -1,8 +1,6 @@
package io.anuke.mindustry.graphics; package io.anuke.mindustry.graphics;
public enum Layer{ public enum Layer{
/**Drawn under everything.*/
shadow,
/**Base block layer.*/ /**Base block layer.*/
block, block,
/**for placement*/ /**for placement*/
+2 -4
View File
@@ -95,6 +95,8 @@ public class Block extends BlockStorage{
public boolean canOverdrive = true; public boolean canOverdrive = true;
/**Whether the icon region has an outline added.*/ /**Whether the icon region has an outline added.*/
public boolean outlineIcon = false; public boolean outlineIcon = false;
/**Whether this block has a shadow under it.*/
public boolean hasShadow = true;
/**Cost of constructing this block.*/ /**Cost of constructing this block.*/
public ItemStack[] buildRequirements = new ItemStack[]{}; public ItemStack[] buildRequirements = new ItemStack[]{};
@@ -230,10 +232,6 @@ public class Block extends BlockStorage{
Draw.rect(region, tile.drawx(), tile.drawy(), rotate ? tile.getRotation() * 90 : 0); Draw.rect(region, tile.drawx(), tile.drawy(), rotate ? tile.getRotation() * 90 : 0);
} }
public void drawShadow(Tile tile){
draw(tile);
}
public void drawTeam(Tile tile){ public void drawTeam(Tile tile){
Draw.color(tile.getTeam().color); Draw.color(tile.getTeam().color);
Draw.rect("block-border", tile.drawx() - size * tilesize/2f + 4, tile.drawy() - size * tilesize/2f + 4); Draw.rect("block-border", tile.drawx() - size * tilesize/2f + 4, tile.drawy() - size * tilesize/2f + 4);
@@ -38,11 +38,6 @@ public class BlockPart extends Block{
//do nothing //do nothing
} }
@Override
public void drawShadow(Tile tile){
//also do nothing
}
@Override @Override
public boolean isSolidFor(Tile tile){ public boolean isSolidFor(Tile tile){
return tile.getLinked() == null return tile.getLinked() == null
@@ -158,12 +158,6 @@ public class BuildBlock extends Block{
} }
} }
@Override
public void drawShadow(Tile tile){
//don't
//TODO maybe do
}
@Override @Override
public TileEntity newEntity(){ public TileEntity newEntity(){
return new BuildEntity(); return new BuildEntity();
@@ -19,12 +19,6 @@ public class TreeBlock extends Block{
@Override @Override
public void draw(Tile tile){} public void draw(Tile tile){}
@Override
public void drawShadow(Tile tile){
Draw.rect(region, tile.drawx(), tile.drawy(), Mathf.randomSeed(tile.pos(), 0, 4) * 90);
Draw.rect(region, tile.drawx() - shadowOffset, tile.drawy() - shadowOffset, Mathf.randomSeed(tile.pos(), 0, 4) * 90);
}
@Override @Override
public void drawLayer(Tile tile){ public void drawLayer(Tile tile){
Draw.rect(region, tile.drawx(), tile.drawy(), Mathf.randomSeed(tile.pos(), 0, 4) * 90); Draw.rect(region, tile.drawx(), tile.drawy(), Mathf.randomSeed(tile.pos(), 0, 4) * 90);