New environment blocks
This commit is contained in:
@@ -40,17 +40,17 @@ public class Blocks{
|
||||
|
||||
//environment
|
||||
air, spawn, cliff, deepwater, water, taintedWater, deepTaintedWater, tar, slag, cryofluid, stone, craters, charr, sand, darksand, dirt, mud, ice, snow, darksandTaintedWater, space, empty,
|
||||
dacite, rhyolite, rhyoliteCrater, roughRhyolite, regolith, yellowStone, redIce,
|
||||
dacite, rhyolite, rhyoliteCrater, roughRhyolite, regolith, yellowStone, redIce, redStone, denseRedStone,
|
||||
arkyciteFloor, arkyicStone,
|
||||
redmat, bluemat,
|
||||
stoneWall, dirtWall, sporeWall, iceWall, daciteWall, sporePine, snowPine, pine, shrubs, whiteTree, whiteTreeDead, sporeCluster,
|
||||
redweed, purbush, coralChunk, yellowCoral,
|
||||
regolithWall, yellowStoneWall, rhyoliteWall, steamVent, carbonWall, redIceWall, ferricStoneWall, beryllicStoneWall, arkyicWall, crystallineStoneWall,
|
||||
regolithWall, yellowStoneWall, rhyoliteWall, steamVent, carbonWall, redIceWall, ferricStoneWall, beryllicStoneWall, arkyicWall, crystallineStoneWall, redStoneWall, redDiamondWall,
|
||||
ferricStone, ferricCraters, carbonStone, beryllicStone, crystallineStone, crystalFloor, yellowStonePlates,
|
||||
iceSnow, sandWater, darksandWater, duneWall, sandWall, moss, sporeMoss, shale, shaleWall, grass, salt,
|
||||
//boulders
|
||||
shaleBoulder, sandBoulder, daciteBoulder, boulder, snowBoulder, basaltBoulder, carbonBoulder, ferricBoulder, beryllicBoulder, yellowStoneBoulder,
|
||||
arkyicBoulder, crystalCluster, vibrantCrystalCluster, crystalBlocks, crystallineBoulder, redIceBoulder, rhyoliteBoulder,
|
||||
arkyicBoulder, crystalCluster, vibrantCrystalCluster, crystalBlocks, crystallineBoulder, redIceBoulder, rhyoliteBoulder, redStoneBoulder,
|
||||
metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor4, metalFloor5, basalt, magmarock, hotrock, snowWall, saltWall,
|
||||
darkPanel1, darkPanel2, darkPanel3, darkPanel4, darkPanel5, darkPanel6, darkMetal,
|
||||
pebbles, tendrils,
|
||||
@@ -180,6 +180,7 @@ public class Blocks{
|
||||
drownTime = 200f;
|
||||
cacheLayer = CacheLayer.water;
|
||||
albedo = 0.9f;
|
||||
supportsOverlay = true;
|
||||
}};
|
||||
|
||||
water = new Floor("shallow-water"){{
|
||||
@@ -191,6 +192,7 @@ public class Blocks{
|
||||
isLiquid = true;
|
||||
cacheLayer = CacheLayer.water;
|
||||
albedo = 0.9f;
|
||||
supportsOverlay = true;
|
||||
}};
|
||||
|
||||
taintedWater = new Floor("tainted-water"){{
|
||||
@@ -203,6 +205,7 @@ public class Blocks{
|
||||
cacheLayer = CacheLayer.water;
|
||||
albedo = 0.9f;
|
||||
attributes.set(Attribute.spores, 0.15f);
|
||||
supportsOverlay = true;
|
||||
}};
|
||||
|
||||
deepTaintedWater = new Floor("deep-tainted-water"){{
|
||||
@@ -216,6 +219,7 @@ public class Blocks{
|
||||
cacheLayer = CacheLayer.water;
|
||||
albedo = 0.9f;
|
||||
attributes.set(Attribute.spores, 0.15f);
|
||||
supportsOverlay = true;
|
||||
}};
|
||||
|
||||
darksandTaintedWater = new ShallowLiquid("darksand-tainted-water"){{
|
||||
@@ -223,18 +227,21 @@ public class Blocks{
|
||||
statusDuration = 60f;
|
||||
albedo = 0.9f;
|
||||
attributes.set(Attribute.spores, 0.1f);
|
||||
supportsOverlay = true;
|
||||
}};
|
||||
|
||||
sandWater = new ShallowLiquid("sand-water"){{
|
||||
speedMultiplier = 0.8f;
|
||||
statusDuration = 50f;
|
||||
albedo = 0.9f;
|
||||
supportsOverlay = true;
|
||||
}};
|
||||
|
||||
darksandWater = new ShallowLiquid("darksand-water"){{
|
||||
speedMultiplier = 0.8f;
|
||||
statusDuration = 50f;
|
||||
albedo = 0.9f;
|
||||
supportsOverlay = true;
|
||||
}};
|
||||
|
||||
tar = new Floor("tar"){{
|
||||
@@ -416,6 +423,16 @@ public class Blocks{
|
||||
variants = 3;
|
||||
}};
|
||||
|
||||
redStone = new Floor("red-stone"){{
|
||||
attributes.set(Attribute.water, -1f);
|
||||
variants = 4;
|
||||
}};
|
||||
|
||||
denseRedStone = new Floor("dense-red-stone"){{
|
||||
attributes.set(Attribute.water, -1f);
|
||||
variants = 4;
|
||||
}};
|
||||
|
||||
redIce = new Floor("red-ice"){{
|
||||
//TODO red ice boulder
|
||||
dragMultiplier = 0.4f;
|
||||
@@ -557,6 +574,15 @@ public class Blocks{
|
||||
redIce.asFloor().wall = this;
|
||||
}};
|
||||
|
||||
redStoneWall = new StaticWall("red-stone-wall"){{
|
||||
redStone.asFloor().wall = denseRedStone.asFloor().wall = this;
|
||||
attributes.set(Attribute.sand, 1.5f);
|
||||
}};
|
||||
|
||||
redDiamondWall = new StaticTree("red-diamond-wall"){{
|
||||
variants = 3;
|
||||
}};
|
||||
|
||||
sandWall = new StaticWall("sand-wall"){{
|
||||
sandWater.asFloor().wall = water.asFloor().wall = deepwater.asFloor().wall = this;
|
||||
attributes.set(Attribute.sand, 2f);
|
||||
@@ -698,6 +724,12 @@ public class Blocks{
|
||||
rhyolite.asFloor().decoration = roughRhyolite.asFloor().decoration = this;
|
||||
}};
|
||||
|
||||
redStoneBoulder = new Prop("red-stone-boulder"){{
|
||||
variants = 4;
|
||||
denseRedStone.asFloor().decoration = redStone.asFloor().decoration = this;
|
||||
}};
|
||||
|
||||
|
||||
metalFloor = new Floor("metal-floor", 0);
|
||||
metalFloorDamaged = new Floor("metal-floor-damaged", 3);
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ public class EditorTile extends Tile{
|
||||
return;
|
||||
}
|
||||
|
||||
if(!floor.hasSurface() && overlay.asFloor().needsSurface) return;
|
||||
if(!floor.hasSurface() && overlay.asFloor().needsSurface && (overlay instanceof OreBlock || !floor.supportsOverlay)) return;
|
||||
if(overlay() == overlay) return;
|
||||
op(OpType.overlay, this.overlay.id);
|
||||
super.setOverlay(overlay);
|
||||
|
||||
@@ -45,7 +45,8 @@ public enum EditorTool{
|
||||
});
|
||||
}
|
||||
},
|
||||
pencil(KeyCode.b, "replace", "square", "drawteams"){
|
||||
//the "under liquid" rendering is too buggy to make public
|
||||
pencil(KeyCode.b, "replace", "square", "drawteams"/*, "underliquid"*/){
|
||||
{
|
||||
edit = true;
|
||||
draggable = true;
|
||||
@@ -61,10 +62,12 @@ public enum EditorTool{
|
||||
editor.drawBlocksReplace(x, y);
|
||||
}else if(mode == 1){
|
||||
//square mode
|
||||
editor.drawBlocks(x, y, true, tile -> true);
|
||||
editor.drawBlocks(x, y, true, false, tile -> true);
|
||||
}else if(mode == 2){
|
||||
//draw teams
|
||||
editor.drawCircle(x, y, tile -> tile.setTeam(editor.drawTeam));
|
||||
}else if(mode == 3){
|
||||
editor.drawBlocks(x, y, false, true, tile -> tile.floor().isLiquid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -116,14 +116,14 @@ public class MapEditor{
|
||||
}
|
||||
|
||||
public void drawBlocks(int x, int y){
|
||||
drawBlocks(x, y, false, tile -> true);
|
||||
drawBlocks(x, y, false, false, tile -> true);
|
||||
}
|
||||
|
||||
public void drawBlocks(int x, int y, Boolf<Tile> tester){
|
||||
drawBlocks(x, y, false, tester);
|
||||
drawBlocks(x, y, false, false, tester);
|
||||
}
|
||||
|
||||
public void drawBlocks(int x, int y, boolean square, Boolf<Tile> tester){
|
||||
public void drawBlocks(int x, int y, boolean square, boolean forceOverlay, Boolf<Tile> tester){
|
||||
if(drawBlock.isMultiblock()){
|
||||
x = Mathf.clamp(x, (drawBlock.size - 1) / 2, width() - drawBlock.size / 2 - 1);
|
||||
y = Mathf.clamp(y, (drawBlock.size - 1) / 2, height() - drawBlock.size / 2 - 1);
|
||||
@@ -137,7 +137,11 @@ public class MapEditor{
|
||||
if(!tester.get(tile)) return;
|
||||
|
||||
if(isFloor){
|
||||
tile.setFloor(drawBlock.asFloor());
|
||||
if(forceOverlay){
|
||||
tile.setOverlay(drawBlock.asFloor());
|
||||
}else{
|
||||
tile.setFloor(drawBlock.asFloor());
|
||||
}
|
||||
}else if(!(tile.block().isMultiblock() && !drawBlock.isMultiblock())){
|
||||
if(drawBlock.rotate && tile.build != null && tile.build.rotation != rotation){
|
||||
addTileOp(TileOp.get(tile.x, tile.y, (byte)OpType.rotation.ordinal(), (byte)rotation));
|
||||
|
||||
@@ -149,6 +149,9 @@ public class MapRenderer implements Disposable{
|
||||
offsetX = tilesize / 2f - region.width / 2f * Draw.scl;
|
||||
offsetY = tilesize / 2f - region.height / 2f * Draw.scl;
|
||||
}else if((wall == Blocks.air || overlay.wallOre) && !overlay.isAir()){
|
||||
if(floor.isLiquid){
|
||||
mesh.setColor(Tmp.c1.set(1f, 1f, 1f, floor.overlayAlpha));
|
||||
}
|
||||
region = overlay.editorVariantRegions()[Mathf.randomSeed(idxWall, 0, tile.overlay().editorVariantRegions().length - 1)];
|
||||
}else{
|
||||
region = clearEditor;
|
||||
|
||||
@@ -10,6 +10,7 @@ import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
|
||||
public abstract class GenerateFilter{
|
||||
public int seed = 0;
|
||||
@@ -37,7 +38,7 @@ public abstract class GenerateFilter{
|
||||
Block block = Vars.content.block(PackTile.block(b)), floor = Vars.content.block(PackTile.floor(b)), overlay = Vars.content.block(PackTile.overlay(b));
|
||||
|
||||
tile.setFloor(floor.asFloor());
|
||||
tile.setOverlay(!floor.asFloor().hasSurface() && overlay.asFloor().needsSurface ? Blocks.air : overlay);
|
||||
tile.setOverlay(!floor.asFloor().hasSurface() && overlay.asFloor().needsSurface && overlay instanceof OreBlock ? Blocks.air : overlay);
|
||||
|
||||
if(!tile.block().synthetic() && !block.synthetic()){
|
||||
tile.setBlock(block);
|
||||
@@ -49,7 +50,7 @@ public abstract class GenerateFilter{
|
||||
apply(in);
|
||||
|
||||
tile.setFloor(in.floor.asFloor());
|
||||
tile.setOverlay(!in.floor.asFloor().hasSurface() && in.overlay.asFloor().needsSurface ? Blocks.air : in.overlay);
|
||||
tile.setOverlay(!in.floor.asFloor().hasSurface() && in.overlay.asFloor().needsSurface && in.overlay instanceof OreBlock ? Blocks.air : in.overlay);
|
||||
|
||||
if(!tile.block().synthetic() && !in.block.synthetic()){
|
||||
tile.setBlock(in.block);
|
||||
|
||||
@@ -402,13 +402,13 @@ public abstract class BasicGenerator implements WorldGenerator{
|
||||
|
||||
for(int i = 0; i < max; i++){
|
||||
Tile tile = tiles.geti(i);
|
||||
if(tile.floor() == floor){
|
||||
if(tile.floor() == floor || tile.block() == floor){
|
||||
for(int cx = -cap; cx <= cap; cx++){
|
||||
for(int cy = -cap; cy <= cap; cy++){
|
||||
if(cx*cx + cy*cy <= r2){
|
||||
Tile other = tiles.get(tile.x + cx, tile.y + cy);
|
||||
|
||||
if(other != null && other.floor() != floor){
|
||||
if(other != null){
|
||||
other.setFloor(dest);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
|
||||
|
||||
Block[][] arr = {
|
||||
{Blocks.regolith, Blocks.regolith, Blocks.yellowStone, Blocks.rhyolite, Blocks.carbonStone}
|
||||
//{Blocks.redStone, Blocks.redStone, Blocks.redStone, Blocks.rhyolite, Blocks.carbonStone}
|
||||
//TODO basalt bad
|
||||
//{Blocks.regolith, Blocks.regolith, Blocks.yellowStone, Blocks.crystallineStone, Blocks.carbonStone}
|
||||
};
|
||||
@@ -193,10 +194,17 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
|
||||
if(floor == Blocks.yellowStonePlates && noise(x + 78 + y, y, 3, 0.8f, 6f, 1f) > 0.44f){
|
||||
floor = Blocks.yellowStone;
|
||||
}
|
||||
|
||||
if(floor == Blocks.redStone && noise(x + 78 - y, y, 4, 0.73f, 20f, 1f) > 0.65f){
|
||||
floor = Blocks.denseRedStone;
|
||||
}
|
||||
});
|
||||
|
||||
inverseFloodFill(tiles.getn(spawnX, spawnY));
|
||||
|
||||
//TODO veins, blend after inverse flood fill?
|
||||
blend(Blocks.redStoneWall, Blocks.denseRedStone, 4);
|
||||
|
||||
//make sure enemies have room
|
||||
erase(endX, endY, 6);
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ import mindustry.graphics.MultiPacker.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class Floor extends Block{
|
||||
@@ -47,6 +49,10 @@ public class Floor extends Block{
|
||||
public float liquidMultiplier = 1f;
|
||||
/** whether this block is liquid. */
|
||||
public boolean isLiquid;
|
||||
/** for liquid floors, this is the opacity of the overlay drawn on top. */
|
||||
public float overlayAlpha = 0.65f;
|
||||
/** whether this floor supports an overlay floor */
|
||||
public boolean supportsOverlay = false;
|
||||
/** shallow water flag used for generation */
|
||||
public boolean shallow = false;
|
||||
/** if true, this block cannot be mined by players. useful for annoying things like sand. */
|
||||
@@ -67,10 +73,13 @@ public class Floor extends Block{
|
||||
public boolean needsSurface = true;
|
||||
/** If true, this ore is allowed on walls. */
|
||||
public boolean wallOre = false;
|
||||
/** Actual ID used for blend groups. Internal. */
|
||||
public int blendId = -1;
|
||||
|
||||
protected TextureRegion[][] edges;
|
||||
protected Seq<Block> blenders = new Seq<>();
|
||||
protected Bits blended = new Bits(256);
|
||||
protected int[] dirs = new int[8];
|
||||
protected TextureRegion edgeRegion;
|
||||
|
||||
public Floor(String name){
|
||||
@@ -109,6 +118,8 @@ public class Floor extends Block{
|
||||
public void init(){
|
||||
super.init();
|
||||
|
||||
blendId = blendGroup.id;
|
||||
|
||||
if(wall == Blocks.air){
|
||||
wall = content.block(name + "-wall");
|
||||
if(wall == null) wall = content.block(name.replace("darksand", "dune") + "-wall");
|
||||
@@ -168,14 +179,21 @@ public class Floor extends Block{
|
||||
Mathf.rand.setSeed(tile.pos());
|
||||
Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.worldx(), tile.worldy());
|
||||
|
||||
Draw.alpha(1f);
|
||||
drawEdges(tile);
|
||||
drawOverlay(tile);
|
||||
}
|
||||
|
||||
public void drawOverlay(Tile tile){
|
||||
Floor floor = tile.overlay();
|
||||
if(floor != Blocks.air && floor != this){ //ore should never have itself on top, but it's possible, so prevent a crash in that case
|
||||
if(floor != Blocks.air && floor != this){
|
||||
if(isLiquid){
|
||||
Draw.alpha(overlayAlpha);
|
||||
}
|
||||
floor.drawBase(tile);
|
||||
if(isLiquid){
|
||||
Draw.alpha(1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +224,7 @@ public class Floor extends Block{
|
||||
public void drawNonLayer(Tile tile, CacheLayer layer){
|
||||
Mathf.rand.setSeed(tile.pos());
|
||||
|
||||
Arrays.fill(dirs, 0);
|
||||
blenders.clear();
|
||||
blended.clear();
|
||||
|
||||
@@ -215,38 +234,44 @@ public class Floor extends Block{
|
||||
if(other != null && other.floor().cacheLayer == layer && other.floor().edges() != null){
|
||||
if(!blended.getAndSet(other.floor().id)){
|
||||
blenders.add(other.floor());
|
||||
dirs[i] = other.floorID();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
drawBlended(tile);
|
||||
drawBlended(tile, false);
|
||||
}
|
||||
|
||||
protected void drawEdges(Tile tile){
|
||||
blenders.clear();
|
||||
blended.clear();
|
||||
Arrays.fill(dirs, 0);
|
||||
CacheLayer realCache = tile.floor().cacheLayer;
|
||||
|
||||
for(int i = 0; i < 8; i++){
|
||||
Point2 point = Geometry.d8[i];
|
||||
Tile other = tile.nearby(point);
|
||||
if(other != null && doEdge(other.floor()) && other.floor().cacheLayer == cacheLayer && other.floor().edges() != null){
|
||||
|
||||
if(other != null && doEdge(tile, other, other.floor()) && other.floor().cacheLayer == realCache && other.floor().edges() != null){
|
||||
|
||||
if(!blended.getAndSet(other.floor().id)){
|
||||
blenders.add(other.floor());
|
||||
}
|
||||
dirs[i] = other.floorID();
|
||||
}
|
||||
}
|
||||
|
||||
drawBlended(tile);
|
||||
drawBlended(tile, true);
|
||||
}
|
||||
|
||||
protected void drawBlended(Tile tile){
|
||||
protected void drawBlended(Tile tile, boolean checkId){
|
||||
blenders.sort(a -> a.id);
|
||||
|
||||
for(Block block : blenders){
|
||||
for(int i = 0; i < 8; i++){
|
||||
Point2 point = Geometry.d8[i];
|
||||
Tile other = tile.nearby(point);
|
||||
if(other != null && other.floor() == block){
|
||||
if(other != null && other.floor() == block && (!checkId || dirs[i] == block.id)){
|
||||
TextureRegion region = edge((Floor)block, 1 - point.x, 1 - point.y);
|
||||
Draw.rect(region, tile.worldx(), tile.worldy());
|
||||
}
|
||||
@@ -258,7 +283,7 @@ public class Floor extends Block{
|
||||
protected void drawEdgesFlat(Tile tile, boolean sameLayer){
|
||||
for(int i = 0; i < 4; i++){
|
||||
Tile other = tile.nearby(i);
|
||||
if(other != null && doEdge(other.floor())){
|
||||
if(other != null && doEdge(tile, other, other.floor())){
|
||||
Color color = other.floor().mapColor;
|
||||
Draw.color(color.r, color.g, color.b, 1f);
|
||||
Draw.rect(edgeRegion, tile.worldx(), tile.worldy(), i*90);
|
||||
@@ -267,13 +292,19 @@ public class Floor extends Block{
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
public int realBlendId(Tile tile){
|
||||
if(tile.floor().isLiquid && !tile.overlay().isAir() && !(tile.overlay() instanceof OreBlock)){
|
||||
return -((tile.overlay().blendId) | (tile.floor().blendId << 15));
|
||||
}
|
||||
return blendId;
|
||||
}
|
||||
|
||||
protected TextureRegion[][] edges(){
|
||||
return ((Floor)blendGroup).edges;
|
||||
}
|
||||
|
||||
protected boolean doEdge(Floor other){
|
||||
return other.blendGroup.id > blendGroup.id || edges() == null;
|
||||
protected boolean doEdge(Tile tile, Tile otherTile, Floor other){
|
||||
return other.realBlendId(otherTile) > realBlendId(tile) || edges() == null;
|
||||
}
|
||||
|
||||
TextureRegion edge(Floor block, int x, int y){
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mindustry.world.blocks.environment;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
@@ -15,9 +16,11 @@ public class StaticTree extends StaticWall{
|
||||
|
||||
@Override
|
||||
public void drawBase(Tile tile){
|
||||
TextureRegion reg = variants > 0 ? variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))] : region;
|
||||
|
||||
TextureRegion r = Tmp.tr1;
|
||||
r.set(region);
|
||||
int crop = (region.width - tilesize*4) / 2;
|
||||
r.set(reg);
|
||||
int crop = (r.width - tilesize*4) / 2;
|
||||
float ox = 0;
|
||||
float oy = 0;
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ public class PayloadDeconstructor extends PayloadBlock{
|
||||
time += edelta();
|
||||
|
||||
for(int i = 0; i < reqs.length; i++){
|
||||
accum[i] += reqs[i].amount * realShift;
|
||||
accum[i] += reqs[i].amount * state.rules.deconstructRefundMultiplier * realShift;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user