Merge branch 'master' of https://github.com/Anuken/Mindustry into 7.0-features

 Conflicts:
	core/src/mindustry/content/Blocks.java
This commit is contained in:
Anuken
2021-06-09 17:10:49 -04:00
93 changed files with 1617 additions and 574 deletions

View File

@@ -1,6 +1,5 @@
package mindustry.maps.filters;
import arc.math.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.gen.*;
@@ -17,7 +16,7 @@ public class BlendFilter extends GenerateFilter{
return Structs.arr(
new SliderOption("radius", () -> radius, f -> radius = f, 1f, 10f),
new BlockOption("block", () -> block, b -> block = b, anyOptional),
new BlockOption("floor", () -> floor, b -> floor = b, floorsOnly),
new BlockOption("floor", () -> floor, b -> floor = b, anyOptional),
new BlockOption("ignore", () -> ignore, b -> ignore = b, floorsOptional)
);
}
@@ -34,7 +33,7 @@ public class BlendFilter extends GenerateFilter{
@Override
public void apply(){
if(in.floor == block || block == Blocks.air || in.floor == ignore) return;
if(in.floor == block || block == Blocks.air || in.floor == ignore || (!floor.isFloor() && (in.block == block || in.block == ignore))) return;
int rad = (int)radius;
boolean found = false;
@@ -42,7 +41,7 @@ public class BlendFilter extends GenerateFilter{
outer:
for(int x = -rad; x <= rad; x++){
for(int y = -rad; y <= rad; y++){
if(Mathf.within(x, y, rad)) continue;
if(x*x + y*y > rad*rad) continue;
Tile tile = in.tile(in.x + x, in.y + y);
if(tile.floor() == block || tile.block() == block || tile.overlay() == block){
@@ -53,7 +52,11 @@ public class BlendFilter extends GenerateFilter{
}
if(found){
in.floor = floor;
if(!floor.isFloor()){
in.block = floor;
}else{
in.floor = floor;
}
}
}
}

View File

@@ -9,7 +9,6 @@ import arc.scene.ui.layout.*;
import mindustry.*;
import mindustry.content.*;
import mindustry.gen.*;
import mindustry.ui.*;
import mindustry.ui.dialogs.*;
import mindustry.world.*;
import mindustry.world.blocks.environment.*;
@@ -105,6 +104,7 @@ public abstract class FilterOption{
if(++i % 10 == 0) dialog.cont.row();
}
dialog.closeOnBack();
dialog.show();
}).pad(4).margin(12f);

View File

@@ -13,7 +13,7 @@ import mindustry.world.*;
public abstract class GenerateFilter{
protected transient float o = (float)(Math.random() * 10000000.0);
protected transient long seed;
protected transient int seed;
protected transient GenerateInput in;
public void apply(Tiles tiles, GenerateInput in){
@@ -75,11 +75,16 @@ public abstract class GenerateFilter{
/** draw any additional guides */
public void draw(Image image){}
/** localized display name */
public String name(){
public String simpleName(){
Class c = getClass();
if(c.isAnonymousClass()) c = c.getSuperclass();
return Core.bundle.get("filter." + c.getSimpleName().toLowerCase().replace("filter", ""), c.getSimpleName().replace("Filter", ""));
return c.getSimpleName().toLowerCase().replace("filter", "");
}
/** localized display name */
public String name(){
var s = simpleName();
return Core.bundle.get("filter." + s);
}
public char icon(){
@@ -112,11 +117,15 @@ public abstract class GenerateFilter{
}
protected float rnoise(float x, float y, float scl, float mag){
return in.pnoise.getValue((int)(x + o), (int)(y + o), 1f / scl) * mag;
return RidgedPerlin.noise2d(seed + 1, (int)(x + o), (int)(y + o), 1f / scl) * mag;
}
protected float rnoise(float x, float y, int octaves, float scl, float falloff, float mag){
return RidgedPerlin.noise2d(seed + 1, (int)(x + o), (int)(y + o), octaves, falloff, 1f / scl) * mag;
}
protected float chance(){
return Mathf.randomSeed(Pack.longInt(in.x, in.y + (int)seed));
return Mathf.randomSeed(Pack.longInt(in.x, in.y + seed));
}
/** an input for generating at a certain coordinate. should only be instantiated once. */
@@ -129,7 +138,6 @@ public abstract class GenerateFilter{
public Block floor, block, overlay;
Simplex noise = new Simplex();
RidgedPerlin pnoise = new RidgedPerlin(0, 1);
TileProvider buffer;
public void apply(int x, int y, Block block, Block floor, Block overlay){
@@ -145,7 +153,6 @@ public abstract class GenerateFilter{
this.width = width;
this.height = height;
noise.setSeed(filter.seed);
pnoise.setSeed((int)(filter.seed + 1));
}
Tile tile(float x, float y){

View File

@@ -10,14 +10,15 @@ import mindustry.world.*;
import static mindustry.Vars.*;
public class MedianFilter extends GenerateFilter{
private static final IntSeq blocks = new IntSeq(), floors = new IntSeq();
float radius = 2;
float percentile = 0.5f;
IntSeq blocks = new IntSeq(), floors = new IntSeq();
@Override
public FilterOption[] options(){
return Structs.arr(
new SliderOption("radius", () -> radius, f -> radius = f, 1f, 12f),
new SliderOption("radius", () -> radius, f -> radius = f, 1f, 10f),
new SliderOption("percentile", () -> percentile, f -> percentile = f, 0f, 1f)
);
}

View File

@@ -8,15 +8,17 @@ import mindustry.world.*;
import static mindustry.maps.filters.FilterOption.*;
public class RiverNoiseFilter extends GenerateFilter{
float scl = 40, threshold = 0f, threshold2 = 0.1f;
float scl = 40, threshold = 0f, threshold2 = 0.1f, octaves = 1, falloff = 0.5f;
Block floor = Blocks.water, floor2 = Blocks.deepwater, block = Blocks.sandWall;
@Override
public FilterOption[] options(){
return Structs.arr(
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f),
new SliderOption("threshold", () -> threshold, f -> threshold = f, -1f, 0.3f),
new SliderOption("threshold2", () -> threshold2, f -> threshold2 = f, -1f, 0.3f),
new SliderOption("threshold", () -> threshold, f -> threshold = f, -1f, 1f),
new SliderOption("threshold2", () -> threshold2, f -> threshold2 = f, -1f, 1f),
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
new BlockOption("block", () -> block, b -> block = b, wallsOnly),
new BlockOption("floor", () -> floor, b -> floor = b, floorsOnly),
new BlockOption("floor2", () -> floor2, b -> floor2 = b, floorsOnly)
@@ -30,7 +32,7 @@ public class RiverNoiseFilter extends GenerateFilter{
@Override
public void apply(){
float noise = rnoise(in.x, in.y, scl, 1f);
float noise = rnoise(in.x, in.y, (int)octaves, scl, falloff, 1f);
if(noise >= threshold){
in.floor = floor;

View File

@@ -18,7 +18,6 @@ import mindustry.world.*;
import static mindustry.Vars.*;
public class SerpuloPlanetGenerator extends PlanetGenerator{
RidgedPerlin rid = new RidgedPerlin(1, 2);
BaseGenerator basegen = new BaseGenerator();
float scl = 5f;
float waterOffset = 0.07f;
@@ -115,7 +114,7 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
tile.floor = getBlock(position);
tile.block = tile.floor.asFloor().wall;
if(rid.getValue(position.x, position.y, position.z, 22) > 0.31){
if(RidgedPerlin.noise3d(1, position.x, position.y, position.z, 2, 22) > 0.31){
tile.block = Blocks.air;
}
}