WIP crystal biome

This commit is contained in:
Anuken
2022-01-18 20:35:43 -05:00
parent f3811d6710
commit 19ddc1dd65
39 changed files with 148 additions and 23 deletions

View File

@@ -294,7 +294,7 @@ public class Block extends UnlockableContent{
public TextureRegion region, editorIcon;
public @Load("@-shadow") TextureRegion customShadowRegion;
public @Load("@-team") TextureRegion teamRegion;
public TextureRegion[] teamRegions, variantRegions;
public TextureRegion[] teamRegions, variantRegions, variantShadowRegions;
protected static final Seq<Tile> tempTiles = new Seq<>();
protected static final Seq<Building> tempTileEnts = new Seq<>();
@@ -314,14 +314,22 @@ public class Block extends UnlockableContent{
if(tile.build != null){
tile.build.draw();
}else{
if(variants == 0){
Draw.rect(region, tile.drawx(), tile.drawy());
}else{
Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.drawx(), tile.drawy());
}
Draw.rect(
variants == 0 ? region :
variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))],
tile.drawx(), tile.drawy());
}
}
public void drawShadow(Tile tile){
Draw.color(0f, 0f, 0f, BlockRenderer.shadowColor.a);
Draw.rect(
variants == 0 ? customShadowRegion :
variantShadowRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantShadowRegions.length - 1))],
tile.drawx(), tile.drawy(), tile.build == null ? 0f : tile.build.drawrot());
Draw.color();
}
public float percentSolid(int x, int y){
Tile tile = world.tile(x, y);
if(tile == null) return 0;
@@ -1019,6 +1027,13 @@ public class Block extends UnlockableContent{
variantRegions[i] = Core.atlas.find(name + (i + 1));
}
region = variantRegions[0];
if(customShadow){
variantShadowRegions = new TextureRegion[variants];
for(int i = 0; i < variants; i++){
variantShadowRegions[i] = Core.atlas.find(name + "-shadow" + (i + 1));
}
}
}
}

View File

@@ -0,0 +1,53 @@
package mindustry.world.blocks.environment;
import arc.*;
import arc.graphics.g2d.*;
import arc.math.*;
import mindustry.graphics.*;
import mindustry.world.*;
//I don't know what else to call this. It's not a prop, it's not a tree.
public class TallBlock extends Block{
public float shadowOffset = -3f;
public float layer = Layer.power + 1;
public float rotationRand = 20f;
public TallBlock(String name){
super(name);
solid = true;
clipSize = 90;
customShadow = true;
}
@Override
public void init(){
super.init();
hasShadow = true;
}
@Override
public void drawBase(Tile tile){
float rot = Mathf.randomSeedRange(tile.pos() + 1, rotationRand);
Draw.z(Layer.power - 1);
Draw.color(0f, 0f, 0f, 0.6f);
Draw.rect(variants > 0 ? variantShadowRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantShadowRegions.length - 1))] : customShadowRegion,
tile.worldx() + shadowOffset, tile.worldy() + shadowOffset, rot);
Draw.color();
Draw.z(Layer.power + 1);
Draw.rect(variants > 0 ? variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))] : region,
tile.worldx(), tile.worldy(), rot);
}
@Override
public void drawShadow(Tile tile){
}
@Override
public TextureRegion[] icons(){
return variants == 0 ? super.icons() : new TextureRegion[]{Core.atlas.find(name + "1")};
}
}