Experimental core-capture PvP map / Editor filter fixes

This commit is contained in:
Anuken
2021-06-16 11:09:18 -04:00
parent fe9ff212b2
commit efcae883fb
6 changed files with 29 additions and 13 deletions

View File

@@ -3,10 +3,10 @@ package mindustry.editor;
import arc.*;
import arc.scene.ui.*;
import arc.struct.*;
import arc.util.*;
import mindustry.*;
import mindustry.game.*;
import mindustry.io.*;
import mindustry.maps.filters.*;
import mindustry.ui.*;
import mindustry.ui.dialogs.*;
@@ -74,7 +74,11 @@ public class MapInfoDialog extends BaseDialog{
t.row();
t.add("@editor.generation").padRight(8).left();
t.button("@edit", () -> {
generate.show(maps.readFilters(editor.tags.get("genfilters", "")),
//randomize so they're not all the same seed
var res = maps.readFilters(editor.tags.get("genfilters", ""));
res.each(GenerateFilter::randomize);
generate.show(res,
filters -> {
//reset seed to 0 so it is not written
filters.each(f -> f.seed = 0);

View File

@@ -29,9 +29,9 @@ import static mindustry.Vars.*;
public class Maps{
/** List of all built-in maps. Filenames only. */
private static String[] defaultMapNames = {"maze", "fortress", "labyrinth", "islands", "tendrils", "caldera", "wasteland", "shattered", "fork", "triad", "mudFlats", "moltenLake", "archipelago", "debrisField", "veins", "glacier"};
private static String[] defaultMapNames = {"maze", "fortress", "labyrinth", "islands", "tendrils", "caldera", "wasteland", "shattered", "fork", "triad", "mudFlats", "moltenLake", "archipelago", "debrisField", "veins", "glacier", "passage"};
/** Maps tagged as PvP */
static final String[] pvpMaps = {"veins", "glacier"};
static final String[] pvpMaps = {"veins", "glacier", "passage"};
/** All maps stored in an ordered array. */
private Seq<Map> maps = new Seq<>();
/** Serializer for meta. */

View File

@@ -7,12 +7,14 @@ import mindustry.world.*;
import static mindustry.maps.filters.FilterOption.*;
public class ClearFilter extends GenerateFilter{
protected Block block = Blocks.air;
protected Block target = Blocks.stone;
protected Block replace = Blocks.air;
@Override
public FilterOption[] options(){
return new BlockOption[]{
new BlockOption("block", () -> block, b -> block = b, b -> oresOnly.get(b) || wallsOnly.get(b))
new BlockOption("target", () -> target, b -> target = b, anyOptional),
new BlockOption("replacement", () -> replace, b -> replace = b, anyOptional)
};
}
@@ -24,12 +26,21 @@ public class ClearFilter extends GenerateFilter{
@Override
public void apply(GenerateInput in){
if(in.block == block){
in.block = Blocks.air;
}
if(in.overlay == block){
in.overlay = Blocks.air;
if(in.block == target || in.floor == target || (target.isOverlay() && in.overlay == target)){
//special case: when air is the result, replace only the overlay or wall
if(replace == Blocks.air){
if(in.overlay == target){
in.overlay = Blocks.air;
}else{
in.block = Blocks.air;
}
}else if(replace.isOverlay()){ //replace the best match based on type
in.overlay = replace;
}else if(replace.isFloor()){
in.floor = replace;
}else{
in.block = replace;
}
}
}
}