Added cliffs as separate block
This commit is contained in:
@@ -33,7 +33,7 @@ public class Blocks implements ContentList{
|
||||
public static Block
|
||||
|
||||
//environment
|
||||
air, spawn, deepwater, water, taintedWater, tar, slag, stone, craters, charr, sand, darksand, ice, snow, darksandTaintedWater,
|
||||
air, spawn, cliff, deepwater, water, taintedWater, tar, slag, stone, craters, charr, sand, darksand, ice, snow, darksandTaintedWater,
|
||||
holostone, rocks, sporerocks, icerocks, cliffs, sporePine, snowPine, pine, shrubs, whiteTree, whiteTreeDead, sporeCluster,
|
||||
iceSnow, sandWater, darksandWater, duneRocks, sandRocks, moss, sporeMoss, shale, shaleRocks, shaleBoulder, sandBoulder, grass, salt,
|
||||
metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor5, ignarock, magmarock, hotrock, snowrocks, rock, snowrock, saltRocks,
|
||||
@@ -123,6 +123,8 @@ public class Blocks implements ContentList{
|
||||
public void draw(Tile tile){}
|
||||
};
|
||||
|
||||
cliff = new Cliff("cliff");
|
||||
|
||||
//Registers build blocks
|
||||
//no reference is needed here since they can be looked up by name later
|
||||
for(int i = 1; i <= BuildBlock.maxSize; i++){
|
||||
|
||||
@@ -45,6 +45,32 @@ public abstract class BasicGenerator implements WorldGenerator{
|
||||
|
||||
}
|
||||
|
||||
public void cliffs(){
|
||||
for(Tile tile : tiles){
|
||||
if(!tile.block().isStatic()) continue;
|
||||
|
||||
int rotation = 0;
|
||||
for(int i = 0; i < 4; i++){
|
||||
Tile other = tiles.get(tile.x + Geometry.d4[i].x, tile.y + Geometry.d4[i].y);
|
||||
if(other != null && !other.block().isStatic()){
|
||||
rotation |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
if(rotation != 0){
|
||||
tile.setBlock(Blocks.cliff);
|
||||
}
|
||||
|
||||
tile.rotation(rotation);
|
||||
}
|
||||
|
||||
for(Tile tile : tiles){
|
||||
if(tile.block() != Blocks.cliff && tile.block().isStatic()){
|
||||
tile.setBlock(Blocks.air);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void median(int radius){
|
||||
median(radius, 0.5);
|
||||
}
|
||||
|
||||
@@ -13,10 +13,11 @@ import mindustry.world.blocks.storage.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class FileMapGenerator implements WorldGenerator{
|
||||
public final Map map;
|
||||
public final Map map = null;
|
||||
|
||||
public FileMapGenerator(String mapName){
|
||||
this.map = maps.loadInternalMap(mapName);
|
||||
//TODO doesn't work
|
||||
//this.map = maps.loadInternalMap(mapName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -123,7 +123,7 @@ public class Tile implements Position{
|
||||
}
|
||||
|
||||
public boolean isDarkened(){
|
||||
return block().solid && !block().synthetic() && block().fillsTile;
|
||||
return block.solid && !block.synthetic() && block.fillsTile;
|
||||
}
|
||||
|
||||
public @NonNull Floor floor(){
|
||||
|
||||
31
core/src/mindustry/world/blocks/Cliff.java
Normal file
31
core/src/mindustry/world/blocks/Cliff.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package mindustry.world.blocks;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class Cliff extends Block{
|
||||
|
||||
public Cliff(String name){
|
||||
super(name);
|
||||
breakable = alwaysReplace = false;
|
||||
solid = true;
|
||||
cacheLayer = CacheLayer.walls;
|
||||
fillsTile = false;
|
||||
hasShadow = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
int r = tile.rotation();
|
||||
for(int i = 0; i < 4; i++){
|
||||
if((r & (1 << i)) != 0){
|
||||
Draw.color(Tmp.c1.set(tile.floor().color).mul(1.3f + (i >= 2 ? -0.4f : 0.3f)));
|
||||
Draw.rect(region, tile.worldx(), tile.worldy(), i * 90f);
|
||||
}
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user