Filter localization / Ore filter / Pick tool ore compatibility
This commit is contained in:
@@ -32,7 +32,7 @@ public enum EditorTool{
|
||||
block = tile.block();
|
||||
}
|
||||
|
||||
editor.drawBlock = block == Blocks.air ? floor : block;
|
||||
editor.drawBlock = block == Blocks.air ? tile.ore() == Blocks.air ? floor : tile.ore() : block;
|
||||
}
|
||||
},
|
||||
pencil{
|
||||
|
||||
@@ -32,7 +32,7 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
private GenerateInput input = new GenerateInput();
|
||||
private Array<GenerateFilter> filters = new Array<>();
|
||||
private int scaling = mobile ? 3 : 1;
|
||||
private Supplier<GenerateFilter>[] filterTypes = new Supplier[]{NoiseFilter::new, ScatterFilter::new, TerrainFilter::new, DistortFilter::new, RiverNoiseFilter::new};
|
||||
private Supplier<GenerateFilter>[] filterTypes = new Supplier[]{NoiseFilter::new, ScatterFilter::new, TerrainFilter::new, DistortFilter::new, RiverNoiseFilter::new, OreFilter::new};
|
||||
private Table filterTable;
|
||||
|
||||
private AsyncExecutor executor = new AsyncExecutor(1);
|
||||
@@ -61,8 +61,6 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
void setup(){
|
||||
filters.clear();
|
||||
|
||||
if(pixmap != null){
|
||||
pixmap.dispose();
|
||||
texture.dispose();
|
||||
@@ -156,9 +154,10 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
void showAdd(){
|
||||
FloatingDialog selection = new FloatingDialog("");
|
||||
FloatingDialog selection = new FloatingDialog("$add");
|
||||
selection.setFillParent(false);
|
||||
selection.cont.defaults().size(210f, 60f);
|
||||
int i = 0;
|
||||
for(Supplier<GenerateFilter> gen : filterTypes){
|
||||
GenerateFilter filter = gen.get();
|
||||
selection.cont.addButton(filter.name(), () -> {
|
||||
@@ -167,7 +166,7 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
update();
|
||||
selection.hide();
|
||||
});
|
||||
selection.cont.row();
|
||||
if(++i % 2 == 0) selection.cont.row();
|
||||
}
|
||||
|
||||
selection.addCloseButton();
|
||||
|
||||
@@ -15,6 +15,7 @@ import io.anuke.mindustry.world.blocks.OreBlock;
|
||||
public abstract class FilterOption{
|
||||
public static final Predicate<Block> floorsOnly = b -> (b instanceof Floor && !(b instanceof OreBlock)) && Core.atlas.isFound(b.icon(Icon.full));
|
||||
public static final Predicate<Block> wallsOnly = b -> (!b.synthetic() && !(b instanceof Floor)) && Core.atlas.isFound(b.icon(Icon.full));
|
||||
public static final Predicate<Block> oresOnly = b -> b instanceof OreBlock && Core.atlas.isFound(b.icon(Icon.full));
|
||||
|
||||
public abstract void build(Table table);
|
||||
public Runnable changed = () -> {};
|
||||
@@ -35,7 +36,7 @@ public abstract class FilterOption{
|
||||
|
||||
@Override
|
||||
public void build(Table table){
|
||||
table.add(name);
|
||||
table.add("$filter.option." + name);
|
||||
table.row();
|
||||
Slider slider = table.addSlider(min, max, (max-min)/200f, setter).growX().get();
|
||||
slider.setValue(getter.get());
|
||||
@@ -78,7 +79,7 @@ public abstract class FilterOption{
|
||||
dialog.show();
|
||||
}).pad(4).margin(12f);
|
||||
|
||||
table.add(name);
|
||||
table.add("$filter.option." + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
32
core/src/io/anuke/mindustry/editor/generation/OreFilter.java
Normal file
32
core/src/io/anuke/mindustry/editor/generation/OreFilter.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package io.anuke.mindustry.editor.generation;
|
||||
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.editor.generation.FilterOption.BlockOption;
|
||||
import io.anuke.mindustry.editor.generation.FilterOption.SliderOption;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
|
||||
import static io.anuke.mindustry.editor.generation.FilterOption.*;
|
||||
|
||||
public class OreFilter extends GenerateFilter{
|
||||
float scl = 40, threshold = 0.8f, octaves = 3f, falloff = 0.5f;
|
||||
Block ore = Blocks.oreCopper;
|
||||
|
||||
{
|
||||
options(
|
||||
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f),
|
||||
new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f),
|
||||
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
|
||||
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
|
||||
new BlockOption("ore", () -> ore, b -> ore = b, oresOnly)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
float noise = noise(in.x, in.y, scl, 1f, octaves, falloff);
|
||||
|
||||
if(noise > threshold && !in.srcfloor.isLiquid){
|
||||
in.ore = ore;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,14 +10,15 @@ import static io.anuke.mindustry.editor.generation.FilterOption.floorsOnly;
|
||||
import static io.anuke.mindustry.editor.generation.FilterOption.wallsOnly;
|
||||
|
||||
public class TerrainFilter extends GenerateFilter{
|
||||
float scl = 40, threshold = 0.9f, octaves = 3f, falloff = 0.5f, circleScl = 2.1f;
|
||||
float scl = 40, threshold = 0.9f, octaves = 3f, falloff = 0.5f, magnitude = 1f, circleScl = 2.1f;
|
||||
Block floor = Blocks.stone, block = Blocks.rocks;
|
||||
|
||||
{
|
||||
options(
|
||||
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f),
|
||||
new SliderOption("mag", () -> magnitude, f -> magnitude = f, 0f, 2f),
|
||||
new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f),
|
||||
new SliderOption("circle scale", () -> circleScl, f -> circleScl = f, 0f, 3f),
|
||||
new SliderOption("circle-scale", () -> circleScl, f -> circleScl = f, 0f, 3f),
|
||||
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
|
||||
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
|
||||
new BlockOption("floor", () -> floor, b -> floor = b, floorsOnly),
|
||||
@@ -27,7 +28,7 @@ public class TerrainFilter extends GenerateFilter{
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
float noise = noise(in.x, in.y, scl, 1f, octaves, falloff) + Mathf.dst((float) in.x / in.editor.width(), (float) in.y / in.editor.height(), 0.5f, 0.5f) * circleScl;
|
||||
float noise = noise(in.x, in.y, scl, magnitude, octaves, falloff) + Mathf.dst((float) in.x / in.editor.width(), (float) in.y / in.editor.height(), 0.5f, 0.5f) * circleScl;
|
||||
|
||||
in.floor = floor;
|
||||
in.ore = Blocks.air;
|
||||
|
||||
Reference in New Issue
Block a user