Partial 7.0 merge - API preview
This commit is contained in:
@@ -15,6 +15,7 @@ import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.defense.*;
|
||||
import mindustry.world.blocks.distribution.*;
|
||||
import mindustry.world.blocks.payloads.*;
|
||||
import mindustry.world.blocks.power.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.meta.*;
|
||||
@@ -103,7 +104,7 @@ public class BaseGenerator{
|
||||
Tile o = tiles.get(tile.x + p.x, tile.y + p.y);
|
||||
|
||||
//do not block payloads
|
||||
if(o != null && (o.block() instanceof PayloadConveyor || o.block() instanceof PayloadAcceptor)){
|
||||
if(o != null && (o.block() instanceof PayloadConveyor || o.block() instanceof PayloadBlock)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,10 @@ public abstract class BasicGenerator implements WorldGenerator{
|
||||
}
|
||||
|
||||
public void tech(){
|
||||
Block[] blocks = {Blocks.darkPanel3};
|
||||
tech(Blocks.darkPanel3, Blocks.darkPanel4, Blocks.darkMetal);
|
||||
}
|
||||
|
||||
public void tech(Block floor1, Block floor2, Block wall){
|
||||
int secSize = 20;
|
||||
pass((x, y) -> {
|
||||
if(!floor.asFloor().hasSurface()) return;
|
||||
@@ -130,14 +133,14 @@ public abstract class BasicGenerator implements WorldGenerator{
|
||||
int sclx = x / secSize, scly = y / secSize;
|
||||
if(noise(sclx, scly, 0.2f, 1f) > 0.63f && noise(sclx, scly + 999, 200f, 1f) > 0.6f && (mx == 0 || my == 0 || mx == secSize - 1 || my == secSize - 1)){
|
||||
if(Mathf.chance(noise(x + 0x231523, y, 40f, 1f))){
|
||||
floor = blocks[rand.random(0, blocks.length - 1)];
|
||||
floor = floor1;
|
||||
if(Mathf.dst(mx, my, secSize/2, secSize/2) > secSize/2f + 2){
|
||||
floor = Blocks.darkPanel4;
|
||||
floor = floor2;
|
||||
}
|
||||
}
|
||||
|
||||
if(block.solid && Mathf.chance(0.7)){
|
||||
block = Blocks.darkMetal;
|
||||
block = wall;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -215,7 +218,9 @@ public abstract class BasicGenerator implements WorldGenerator{
|
||||
read.set(write);
|
||||
}
|
||||
|
||||
tiles.each((x, y) -> tiles.get(x, y).setBlock(!read.get(x, y) ? Blocks.air : tiles.get(x, y).floor().wall));
|
||||
for(var t : tiles){
|
||||
t.setBlock(!read.get(t.x, t.y) ? Blocks.air : t.floor().wall);
|
||||
}
|
||||
}
|
||||
|
||||
protected float noise(float x, float y, double scl, double mag){
|
||||
|
||||
@@ -2,12 +2,19 @@ package mindustry.maps.generators;
|
||||
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.struct.ObjectIntMap.*;
|
||||
import arc.util.noise.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.graphics.g3d.*;
|
||||
import mindustry.graphics.g3d.PlanetGrid.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.type.Weather.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public abstract class PlanetGenerator extends BasicGenerator implements HexMesher{
|
||||
protected IntSeq ints = new IntSeq();
|
||||
protected Sector sector;
|
||||
@@ -43,6 +50,65 @@ public abstract class PlanetGenerator extends BasicGenerator implements HexMeshe
|
||||
}
|
||||
}
|
||||
|
||||
public void addWeather(Sector sector, Rules rules){
|
||||
|
||||
//apply weather based on terrain
|
||||
ObjectIntMap<Block> floorc = new ObjectIntMap<>();
|
||||
ObjectSet<UnlockableContent> content = new ObjectSet<>();
|
||||
|
||||
for(Tile tile : world.tiles){
|
||||
if(world.getDarkness(tile.x, tile.y) >= 3){
|
||||
continue;
|
||||
}
|
||||
|
||||
Liquid liquid = tile.floor().liquidDrop;
|
||||
if(tile.floor().itemDrop != null) content.add(tile.floor().itemDrop);
|
||||
if(tile.overlay().itemDrop != null) content.add(tile.overlay().itemDrop);
|
||||
if(liquid != null) content.add(liquid);
|
||||
|
||||
if(!tile.block().isStatic()){
|
||||
floorc.increment(tile.floor());
|
||||
if(tile.overlay() != Blocks.air){
|
||||
floorc.increment(tile.overlay());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//sort counts in descending order
|
||||
Seq<Entry<Block>> entries = floorc.entries().toArray();
|
||||
entries.sort(e -> -e.value);
|
||||
//remove all blocks occuring < 30 times - unimportant
|
||||
entries.removeAll(e -> e.value < 30);
|
||||
|
||||
Block[] floors = new Block[entries.size];
|
||||
for(int i = 0; i < entries.size; i++){
|
||||
floors[i] = entries.get(i).key;
|
||||
}
|
||||
|
||||
//TODO bad code
|
||||
boolean hasSnow = floors.length > 0 && (floors[0].name.contains("ice") || floors[0].name.contains("snow"));
|
||||
boolean hasRain = floors.length > 0 && !hasSnow && content.contains(Liquids.water) && !floors[0].name.contains("sand");
|
||||
boolean hasDesert = floors.length > 0 && !hasSnow && !hasRain && floors[0] == Blocks.sand;
|
||||
boolean hasSpores = floors.length > 0 && (floors[0].name.contains("spore") || floors[0].name.contains("moss") || floors[0].name.contains("tainted"));
|
||||
|
||||
if(hasSnow){
|
||||
rules.weather.add(new WeatherEntry(Weathers.snow));
|
||||
}
|
||||
|
||||
if(hasRain){
|
||||
rules.weather.add(new WeatherEntry(Weathers.rain));
|
||||
rules.weather.add(new WeatherEntry(Weathers.fog));
|
||||
}
|
||||
|
||||
if(hasDesert){
|
||||
rules.weather.add(new WeatherEntry(Weathers.sandstorm));
|
||||
}
|
||||
|
||||
if(hasSpores){
|
||||
rules.weather.add(new WeatherEntry(Weathers.sporestorm));
|
||||
}
|
||||
}
|
||||
|
||||
protected void genTile(Vec3 position, TileGen tile){
|
||||
|
||||
}
|
||||
@@ -53,6 +119,11 @@ public abstract class PlanetGenerator extends BasicGenerator implements HexMeshe
|
||||
return (float)noise.octaveNoise3D(octaves, falloff, 1f / scl, v.x, v.y, v.z) * (float)mag;
|
||||
}
|
||||
|
||||
/** @return the scaling factor for sector rects. */
|
||||
public float getSizeScl(){
|
||||
return 3200;
|
||||
}
|
||||
|
||||
public void generate(Tiles tiles, Sector sec){
|
||||
this.tiles = tiles;
|
||||
this.sector = sec;
|
||||
|
||||
Reference in New Issue
Block a user