Seq.
This commit is contained in:
@@ -111,9 +111,9 @@ public class Map implements Comparable<Map>, Publishable{
|
||||
}
|
||||
|
||||
/** Returns the generation filters that this map uses on load.*/
|
||||
public Array<GenerateFilter> filters(){
|
||||
public Seq<GenerateFilter> filters(){
|
||||
if(tags.getInt("build", -1) < 83 && tags.getInt("build", -1) != -1 && tags.get("genfilters", "").isEmpty()){
|
||||
return Array.with();
|
||||
return Seq.with();
|
||||
}
|
||||
return maps.readFilters(tags.get("genfilters", ""));
|
||||
}
|
||||
@@ -196,9 +196,9 @@ public class Map implements Comparable<Map>, Publishable{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array<String> extraTags(){
|
||||
public Seq<String> extraTags(){
|
||||
Gamemode mode = Gamemode.attack.valid(this) ? Gamemode.attack : Gamemode.survival;
|
||||
return Array.with(mode.name());
|
||||
return Seq.with(mode.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,8 +43,8 @@ public class MapPreviewLoader extends TextureLoader{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array<AssetDescriptor> getDependencies(String fileName, Fi file, TextureParameter parameter){
|
||||
return Array.with(new AssetDescriptor<>("contentcreate", Content.class));
|
||||
public Seq<AssetDescriptor> getDependencies(String fileName, Fi file, TextureParameter parameter){
|
||||
return Seq.with(new AssetDescriptor<>("contentcreate", Content.class));
|
||||
}
|
||||
|
||||
public static class MapPreviewParameter extends TextureParameter{
|
||||
|
||||
@@ -32,7 +32,7 @@ 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", "veins", "glacier"};
|
||||
/** All maps stored in an ordered array. */
|
||||
private Array<Map> maps = new Array<>();
|
||||
private Seq<Map> maps = new Seq<>();
|
||||
/** Serializer for meta. */
|
||||
private Json json = new Json();
|
||||
|
||||
@@ -61,17 +61,17 @@ public class Maps{
|
||||
}
|
||||
|
||||
/** Returns a list of all maps, including custom ones. */
|
||||
public Array<Map> all(){
|
||||
public Seq<Map> all(){
|
||||
return maps;
|
||||
}
|
||||
|
||||
/** Returns a list of only custom maps. */
|
||||
public Array<Map> customMaps(){
|
||||
public Seq<Map> customMaps(){
|
||||
return maps.select(m -> m.custom);
|
||||
}
|
||||
|
||||
/** Returns a list of only default maps. */
|
||||
public Array<Map> defaultMaps(){
|
||||
public Seq<Map> defaultMaps(){
|
||||
return maps.select(m -> !m.custom);
|
||||
}
|
||||
|
||||
@@ -298,10 +298,10 @@ public class Maps{
|
||||
|
||||
/** Reads JSON of filters, returning a new default array if not found.*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Array<GenerateFilter> readFilters(String str){
|
||||
public Seq<GenerateFilter> readFilters(String str){
|
||||
if(str == null || str.isEmpty()){
|
||||
//create default filters list
|
||||
Array<GenerateFilter> filters = Array.with(
|
||||
Seq<GenerateFilter> filters = Seq.with(
|
||||
new ScatterFilter(){{
|
||||
flooronto = Blocks.stone;
|
||||
block = Blocks.rock;
|
||||
@@ -329,7 +329,7 @@ public class Maps{
|
||||
return filters;
|
||||
}else{
|
||||
try{
|
||||
return JsonIO.read(Array.class, str);
|
||||
return JsonIO.read(Seq.class, str);
|
||||
}catch(Throwable e){
|
||||
e.printStackTrace();
|
||||
return readFilters("");
|
||||
@@ -337,8 +337,8 @@ public class Maps{
|
||||
}
|
||||
}
|
||||
|
||||
public void addDefaultOres(Array<GenerateFilter> filters){
|
||||
Array<Block> ores = content.blocks().select(b -> b.isOverlay() && b.asFloor().oreDefault);
|
||||
public void addDefaultOres(Seq<GenerateFilter> filters){
|
||||
Seq<Block> ores = content.blocks().select(b -> b.isOverlay() && b.asFloor().oreDefault);
|
||||
for(Block block : ores){
|
||||
OreFilter filter = new OreFilter();
|
||||
filter.threshold = block.asFloor().oreThreshold;
|
||||
@@ -348,7 +348,7 @@ public class Maps{
|
||||
}
|
||||
}
|
||||
|
||||
public String writeWaves(Array<SpawnGroup> groups){
|
||||
public String writeWaves(Seq<SpawnGroup> groups){
|
||||
if(groups == null) return "[]";
|
||||
|
||||
StringWriter buffer = new StringWriter();
|
||||
@@ -364,8 +364,8 @@ public class Maps{
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
public Array<SpawnGroup> readWaves(String str){
|
||||
return str == null ? null : str.equals("[]") ? new Array<>() : Array.with(json.fromJson(SpawnGroup[].class, str));
|
||||
public Seq<SpawnGroup> readWaves(String str){
|
||||
return str == null ? null : str.equals("[]") ? new Seq<>() : Seq.with(json.fromJson(SpawnGroup[].class, str));
|
||||
}
|
||||
|
||||
public void loadPreviews(){
|
||||
@@ -473,17 +473,17 @@ public class Maps{
|
||||
public enum ShuffleMode implements MapProvider{
|
||||
none(map -> null),
|
||||
all(prev -> {
|
||||
Array<Map> maps = Array.withArrays(Vars.maps.defaultMaps(), Vars.maps.customMaps());
|
||||
Seq<Map> maps = Seq.withArrays(Vars.maps.defaultMaps(), Vars.maps.customMaps());
|
||||
maps.shuffle();
|
||||
return maps.find(m -> m != prev || maps.size == 1);
|
||||
}),
|
||||
custom(prev -> {
|
||||
Array<Map> maps = Array.withArrays(Vars.maps.customMaps().isEmpty() ? Vars.maps.defaultMaps() : Vars.maps.customMaps());
|
||||
Seq<Map> maps = Seq.withArrays(Vars.maps.customMaps().isEmpty() ? Vars.maps.defaultMaps() : Vars.maps.customMaps());
|
||||
maps.shuffle();
|
||||
return maps.find(m -> m != prev || maps.size == 1);
|
||||
}),
|
||||
builtin(prev -> {
|
||||
Array<Map> maps = Array.withArrays(Vars.maps.defaultMaps());
|
||||
Seq<Map> maps = Seq.withArrays(Vars.maps.defaultMaps());
|
||||
maps.shuffle();
|
||||
return maps.find(m -> m != prev || maps.size == 1);
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ public class CoreSpawnFilter extends GenerateFilter{
|
||||
|
||||
@Override
|
||||
public void apply(Tiles tiles, GenerateInput in){
|
||||
IntArray spawns = new IntArray();
|
||||
IntSeq spawns = new IntSeq();
|
||||
for(Tile tile : tiles){
|
||||
if(tile.team() == state.rules.defaultTeam && tile.block() instanceof CoreBlock && tile.isCenter()){
|
||||
spawns.add(tile.pos());
|
||||
|
||||
@@ -19,7 +19,7 @@ public class EnemySpawnFilter extends GenerateFilter{
|
||||
|
||||
@Override
|
||||
public void apply(Tiles tiles, GenerateInput in){
|
||||
IntArray spawns = new IntArray();
|
||||
IntSeq spawns = new IntSeq();
|
||||
for(Tile tile : tiles){
|
||||
if(tile.overlay() == Blocks.spawn){
|
||||
spawns.add(tile.pos());
|
||||
|
||||
@@ -11,7 +11,7 @@ import static mindustry.Vars.content;
|
||||
public class MedianFilter extends GenerateFilter{
|
||||
float radius = 2;
|
||||
float percentile = 0.5f;
|
||||
IntArray blocks = new IntArray(), floors = new IntArray();
|
||||
IntSeq blocks = new IntSeq(), floors = new IntSeq();
|
||||
|
||||
@Override
|
||||
public FilterOption[] options(){
|
||||
|
||||
@@ -12,7 +12,7 @@ public class OreMedianFilter extends GenerateFilter{
|
||||
public float radius = 2;
|
||||
public float percentile = 0.5f;
|
||||
|
||||
private IntArray blocks = new IntArray();
|
||||
private IntSeq blocks = new IntSeq();
|
||||
|
||||
@Override
|
||||
public FilterOption[] options(){
|
||||
|
||||
@@ -7,7 +7,7 @@ import mindustry.world.*;
|
||||
import mindustry.world.blocks.storage.*;
|
||||
|
||||
public class RandomItemFilter extends GenerateFilter{
|
||||
public Array<ItemStack> drops = new Array<>();
|
||||
public Seq<ItemStack> drops = new Seq<>();
|
||||
public float chance = 0.3f;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,9 +26,9 @@ public class BaseGenerator{
|
||||
private Tiles tiles;
|
||||
private Team team;
|
||||
private ObjectMap<Item, OreBlock> ores = new ObjectMap<>();
|
||||
private Array<Tile> cores;
|
||||
private Seq<Tile> cores;
|
||||
|
||||
public void generate(Tiles tiles, Array<Tile> cores, Tile spawn, Team team, Sector sector){
|
||||
public void generate(Tiles tiles, Seq<Tile> cores, Tile spawn, Team team, Sector sector){
|
||||
this.tiles = tiles;
|
||||
this.team = team;
|
||||
this.cores = cores;
|
||||
@@ -42,8 +42,8 @@ public class BaseGenerator{
|
||||
|
||||
float costBudget = 1000;
|
||||
|
||||
Array<Block> wallsSmall = content.blocks().select(b -> b instanceof Wall && b.size == 1);
|
||||
Array<Block> wallsLarge = content.blocks().select(b -> b instanceof Wall && b.size == 2);
|
||||
Seq<Block> wallsSmall = content.blocks().select(b -> b instanceof Wall && b.size == 1);
|
||||
Seq<Block> wallsLarge = content.blocks().select(b -> b instanceof Wall && b.size == 2);
|
||||
|
||||
float bracket = 0.1f;
|
||||
int wallAngle = 70; //180 for full coverage
|
||||
@@ -69,7 +69,7 @@ public class BaseGenerator{
|
||||
if(!tile.block().alwaysReplace) return;
|
||||
|
||||
if((tile.drop() != null || (tile.floor().liquidDrop != null && Mathf.chance(nonResourceChance * 2))) && Mathf.chance(resourceChance)){
|
||||
Array<BasePart> parts = bases.forResource(tile.drop() != null ? tile.drop() : tile.floor().liquidDrop);
|
||||
Seq<BasePart> parts = bases.forResource(tile.drop() != null ? tile.drop() : tile.floor().liquidDrop);
|
||||
if(!parts.isEmpty()){
|
||||
tryPlace(parts.random(), tile.x, tile.y);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import mindustry.world.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public abstract class BasicGenerator implements WorldGenerator{
|
||||
protected static final ShortArray ints1 = new ShortArray(), ints2 = new ShortArray();
|
||||
protected static final ShortSeq ints1 = new ShortSeq(), ints2 = new ShortSeq();
|
||||
|
||||
protected Rand rand = new Rand();
|
||||
|
||||
@@ -124,7 +124,7 @@ public abstract class BasicGenerator implements WorldGenerator{
|
||||
});
|
||||
}
|
||||
|
||||
public void ores(Array<Block> ores){
|
||||
public void ores(Seq<Block> ores){
|
||||
pass((x, y) -> {
|
||||
if(floor.asFloor().isLiquid) return;
|
||||
|
||||
@@ -297,7 +297,7 @@ public abstract class BasicGenerator implements WorldGenerator{
|
||||
}
|
||||
}
|
||||
|
||||
public void brush(Array<Tile> path, int rad){
|
||||
public void brush(Seq<Tile> path, int rad){
|
||||
path.each(tile -> erase(tile.x, tile.y, rad));
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ public abstract class BasicGenerator implements WorldGenerator{
|
||||
}
|
||||
}
|
||||
|
||||
public Array<Tile> pathfind(int startX, int startY, int endX, int endY, TileHueristic th, DistanceHeuristic dh){
|
||||
public Seq<Tile> pathfind(int startX, int startY, int endX, int endY, TileHueristic th, DistanceHeuristic dh){
|
||||
return Astar.pathfind(startX, startY, endX, endY, th, dh, tile -> world.getDarkness(tile.x, tile.y) <= 1f);
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ public abstract class BasicGenerator implements WorldGenerator{
|
||||
}
|
||||
|
||||
public void inverseFloodFill(Tile start){
|
||||
IntArray arr = new IntArray();
|
||||
IntSeq arr = new IntSeq();
|
||||
arr.add(start.pos());
|
||||
while(!arr.isEmpty()){
|
||||
int i = arr.pop();
|
||||
|
||||
@@ -143,7 +143,7 @@ public class TODOPlanetGenerator extends PlanetGenerator{
|
||||
float constraint = 1.3f;
|
||||
float radius = width / 2f / Mathf.sqrt3;
|
||||
int rooms = rand.random(2, 5);
|
||||
Array<Room> array = new Array<>();
|
||||
Seq<Room> array = new Seq<>();
|
||||
|
||||
for(int i = 0; i < rooms; i++){
|
||||
Tmp.v1.trns(rand.random(360f), rand.random(radius / constraint));
|
||||
@@ -156,7 +156,7 @@ public class TODOPlanetGenerator extends PlanetGenerator{
|
||||
|
||||
//check positions on the map to place the player spawn. this needs to be in the corner of the map
|
||||
Room spawn = null;
|
||||
Array<Room> enemies = new Array<>();
|
||||
Seq<Room> enemies = new Seq<>();
|
||||
int enemySpawns = rand.chance(0.3) ? 2 : 1;
|
||||
int offset = rand.nextInt(360);
|
||||
float length = width/2.55f - rand.random(13, 23);
|
||||
@@ -212,7 +212,7 @@ public class TODOPlanetGenerator extends PlanetGenerator{
|
||||
|
||||
inverseFloodFill(tiles.getn(spawn.x, spawn.y));
|
||||
|
||||
Array<Block> ores = Array.with(Blocks.oreCopper, Blocks.oreLead);
|
||||
Seq<Block> ores = Seq.with(Blocks.oreCopper, Blocks.oreLead);
|
||||
float poles = Math.abs(sector.tile.v.y);
|
||||
float nmag = 0.5f;
|
||||
float scl = 1f;
|
||||
@@ -230,7 +230,7 @@ public class TODOPlanetGenerator extends PlanetGenerator{
|
||||
ores.add(Blocks.oreThorium);
|
||||
}
|
||||
|
||||
FloatArray frequencies = new FloatArray();
|
||||
FloatSeq frequencies = new FloatSeq();
|
||||
for(int i = 0; i < ores.size; i++){
|
||||
frequencies.add(rand.random(-0.09f, 0.01f) - i * 0.01f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user