Seq.
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
package mindustry.game;
|
||||
|
||||
import arc.struct.Array;
|
||||
import arc.struct.Seq;
|
||||
import mindustry.content.*;
|
||||
import mindustry.type.ItemStack;
|
||||
|
||||
public class DefaultWaves{
|
||||
private Array<SpawnGroup> spawns;
|
||||
private Seq<SpawnGroup> spawns;
|
||||
|
||||
public Array<SpawnGroup> get(){
|
||||
public Seq<SpawnGroup> get(){
|
||||
if(spawns == null && UnitTypes.dagger != null){
|
||||
spawns = Array.with(
|
||||
spawns = Seq.with(
|
||||
new SpawnGroup(UnitTypes.dagger){{
|
||||
end = 10;
|
||||
unitScaling = 2f;
|
||||
@@ -186,6 +186,6 @@ public class DefaultWaves{
|
||||
}}
|
||||
);
|
||||
}
|
||||
return spawns == null ? new Array<>() : spawns;
|
||||
return spawns == null ? new Seq<>() : spawns;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class GlobalData{
|
||||
private boolean modified;
|
||||
|
||||
public void exportData(Fi file) throws IOException{
|
||||
Array<Fi> files = new Array<>();
|
||||
Seq<Fi> files = new Seq<>();
|
||||
files.add(Core.settings.getSettingsFile());
|
||||
files.addAll(customMapDirectory.list());
|
||||
files.addAll(saveDirectory.list());
|
||||
@@ -85,7 +85,7 @@ public class GlobalData{
|
||||
modified = true;
|
||||
}
|
||||
|
||||
public boolean hasItems(Array<ItemStack> stacks){
|
||||
public boolean hasItems(Seq<ItemStack> stacks){
|
||||
return !stacks.contains(s -> items.get(s.item, 0) < s.amount);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class GlobalData{
|
||||
}
|
||||
}
|
||||
|
||||
public void removeItems(Array<ItemStack> stacks){
|
||||
public void removeItems(Seq<ItemStack> stacks){
|
||||
for(ItemStack stack : stacks){
|
||||
remove(stack.item, stack.amount);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class Rules{
|
||||
/** Sector for saves that have them.*/
|
||||
public @Nullable Sector sector;
|
||||
/** Spawn layout. */
|
||||
public Array<SpawnGroup> spawns = new Array<>();
|
||||
public Seq<SpawnGroup> spawns = new Seq<>();
|
||||
/** Whether to pause the wave timer until all enemies are destroyed. */
|
||||
public boolean waitEnemies = false;
|
||||
/** Determinates if gamemode is attack mode */
|
||||
@@ -74,9 +74,9 @@ public class Rules{
|
||||
/** EXPERIMENTAL building AI. TODO remove */
|
||||
public boolean buildAI = true;
|
||||
/** Starting items put in cores */
|
||||
public Array<ItemStack> loadout = Array.with(ItemStack.with(Items.copper, 100));
|
||||
public Seq<ItemStack> loadout = Seq.with(ItemStack.with(Items.copper, 100));
|
||||
/** Weather events that occur here. */
|
||||
public Array<WeatherEntry> weather = new Array<>(1);
|
||||
public Seq<WeatherEntry> weather = new Seq<>(1);
|
||||
/** Blocks that cannot be placed. */
|
||||
public ObjectSet<Block> bannedBlocks = new ObjectSet<>();
|
||||
/** Whether everything is dark. Enables lights. Experimental. */
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class Saves{
|
||||
private Array<SaveSlot> saves = new Array<>();
|
||||
private Seq<SaveSlot> saves = new Seq<>();
|
||||
private @Nullable SaveSlot current;
|
||||
private @Nullable SaveSlot lastSectorSave;
|
||||
private AsyncExecutor previewExecutor = new AsyncExecutor(1);
|
||||
@@ -160,7 +160,7 @@ public class Saves{
|
||||
return file;
|
||||
}
|
||||
|
||||
public Array<SaveSlot> getSaveSlots(){
|
||||
public Seq<SaveSlot> getSaveSlots(){
|
||||
return saves;
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ public class Saves{
|
||||
}
|
||||
|
||||
public void cautiousLoad(Runnable run){
|
||||
Array<String> mods = Array.with(getMods());
|
||||
Seq<String> mods = Seq.with(getMods());
|
||||
mods.removeAll(Vars.mods.getModStrings());
|
||||
|
||||
if(!mods.isEmpty()){
|
||||
|
||||
@@ -14,21 +14,21 @@ import mindustry.world.blocks.storage.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class Schematic implements Publishable, Comparable<Schematic>{
|
||||
public final Array<Stile> tiles;
|
||||
public final Seq<Stile> tiles;
|
||||
public StringMap tags;
|
||||
public int width, height;
|
||||
public @Nullable Fi file;
|
||||
/** Associated mod. If null, no mod is associated with this schematic. */
|
||||
public @Nullable LoadedMod mod;
|
||||
|
||||
public Schematic(Array<Stile> tiles, @NonNull StringMap tags, int width, int height){
|
||||
public Schematic(Seq<Stile> tiles, @NonNull StringMap tags, int width, int height){
|
||||
this.tiles = tiles;
|
||||
this.tags = tags;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public Array<ItemStack> requirements(){
|
||||
public Seq<ItemStack> requirements(){
|
||||
IntIntMap amounts = new IntIntMap();
|
||||
|
||||
tiles.each(t -> {
|
||||
@@ -36,7 +36,7 @@ public class Schematic implements Publishable, Comparable<Schematic>{
|
||||
amounts.getAndIncrement(stack.item.id, 0, stack.amount);
|
||||
}
|
||||
});
|
||||
Array<ItemStack> stacks = new Array<>();
|
||||
Seq<ItemStack> stacks = new Seq<>();
|
||||
for(Entry ent : amounts.entries()){
|
||||
stacks.add(new ItemStack(Vars.content.item(ent.key), ent.value));
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ import static mindustry.Vars.*;
|
||||
|
||||
/** Handles schematics.*/
|
||||
public class Schematics implements Loadable{
|
||||
private static final Schematic tmpSchem = new Schematic(new Array<>(), new StringMap(), 0, 0);
|
||||
private static final Schematic tmpSchem2 = new Schematic(new Array<>(), new StringMap(), 0, 0);
|
||||
private static final Schematic tmpSchem = new Schematic(new Seq<>(), new StringMap(), 0, 0);
|
||||
private static final Schematic tmpSchem2 = new Schematic(new Seq<>(), new StringMap(), 0, 0);
|
||||
public static final String base64Header = "bXNjaAB";
|
||||
|
||||
private static final byte[] header = {'m', 's', 'c', 'h'};
|
||||
@@ -52,7 +52,7 @@ public class Schematics implements Loadable{
|
||||
private static final int resolution = 32;
|
||||
|
||||
private OptimizedByteArrayOutputStream out = new OptimizedByteArrayOutputStream(1024);
|
||||
private Array<Schematic> all = new Array<>();
|
||||
private Seq<Schematic> all = new Seq<>();
|
||||
private OrderedMap<Schematic, FrameBuffer> previews = new OrderedMap<>();
|
||||
private ObjectSet<Schematic> errored = new ObjectSet<>();
|
||||
private FrameBuffer shadowBuffer;
|
||||
@@ -155,7 +155,7 @@ public class Schematics implements Loadable{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Array<Schematic> all(){
|
||||
public Seq<Schematic> all(){
|
||||
return all;
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public class Schematics implements Loadable{
|
||||
//dispose unneeded previews to prevent memory outage errors.
|
||||
//only runs every 2 seconds
|
||||
if(mobile && Time.timeSinceMillis(lastClearTime) > 1000 * 2 && previews.size > maxPreviewsMobile){
|
||||
Array<Schematic> keys = previews.orderedKeys().copy();
|
||||
Seq<Schematic> keys = previews.orderedKeys().copy();
|
||||
for(int i = 0; i < previews.size - maxPreviewsMobile; i++){
|
||||
//dispose and remove unneeded previews
|
||||
previews.get(keys.get(i)).dispose();
|
||||
@@ -246,7 +246,7 @@ public class Schematics implements Loadable{
|
||||
Draw.rect(Tmp.tr1, buffer.getWidth()/2f, buffer.getHeight()/2f, buffer.getWidth(), -buffer.getHeight());
|
||||
Draw.color();
|
||||
|
||||
Array<BuildRequest> requests = schematic.tiles.map(t -> new BuildRequest(t.x, t.y, t.rotation, t.block).configure(t.config));
|
||||
Seq<BuildRequest> requests = schematic.tiles.map(t -> new BuildRequest(t.x, t.y, t.rotation, t.block).configure(t.config));
|
||||
|
||||
Draw.flush();
|
||||
//scale each request to fit schematic
|
||||
@@ -276,7 +276,7 @@ public class Schematics implements Loadable{
|
||||
}
|
||||
|
||||
/** Creates an array of build requests from a schematic's data, centered on the provided x+y coordinates. */
|
||||
public Array<BuildRequest> toRequests(Schematic schem, int x, int y){
|
||||
public Seq<BuildRequest> toRequests(Schematic schem, int x, int y){
|
||||
return schem.tiles.map(t -> new BuildRequest(t.x + x - schem.width/2, t.y + y - schem.height/2, t.rotation, t.block).original(t.x, t.y, schem.width, schem.height).configure(t.config))
|
||||
.removeAll(s -> !s.block.isVisible() || !s.block.unlockedCur());
|
||||
}
|
||||
@@ -318,7 +318,7 @@ public class Schematics implements Loadable{
|
||||
|
||||
int ox = x, oy = y, ox2 = x2, oy2 = y2;
|
||||
|
||||
Array<Stile> tiles = new Array<>();
|
||||
Seq<Stile> tiles = new Seq<>();
|
||||
|
||||
int minx = x2, miny = y2, maxx = x, maxy = y;
|
||||
boolean found = false;
|
||||
@@ -344,7 +344,7 @@ public class Schematics implements Loadable{
|
||||
x2 = maxx;
|
||||
y2 = maxy;
|
||||
}else{
|
||||
return new Schematic(new Array<>(), new StringMap(), 1, 1);
|
||||
return new Schematic(new Seq<>(), new StringMap(), 1, 1);
|
||||
}
|
||||
|
||||
int width = x2 - x + 1, height = y2 - y + 1;
|
||||
@@ -466,7 +466,7 @@ public class Schematics implements Loadable{
|
||||
}
|
||||
|
||||
int total = stream.readInt();
|
||||
Array<Stile> tiles = new Array<>(total);
|
||||
Seq<Stile> tiles = new Seq<>(total);
|
||||
for(int i = 0; i < total; i++){
|
||||
Block block = blocks.get(stream.readByte());
|
||||
int position = stream.readInt();
|
||||
|
||||
@@ -39,7 +39,7 @@ public class Stats{
|
||||
|
||||
//weigh used fractions
|
||||
float frac = 0f;
|
||||
Array<Item> obtainable = Array.select(zone.data.resources, i -> i instanceof Item && ((Item)i).type == ItemType.material).as();
|
||||
Seq<Item> obtainable = Seq.select(zone.data.resources, i -> i instanceof Item && ((Item)i).type == ItemType.material).as();
|
||||
for(Item item : obtainable){
|
||||
frac += Mathf.clamp((float)itemsDelivered.get(item, 0) / capacity) / (float)obtainable.size;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class Team implements Comparable<Team>{
|
||||
all[us] = this;
|
||||
}
|
||||
|
||||
public Array<Team> enemies(){
|
||||
public Seq<Team> enemies(){
|
||||
return state.teams.enemiesOf(this);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class Team implements Comparable<Team>{
|
||||
return state.teams.areEnemies(this, other);
|
||||
}
|
||||
|
||||
public Array<CoreEntity> cores(){
|
||||
public Seq<CoreEntity> cores(){
|
||||
return state.teams.cores(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public class Teams{
|
||||
/** Maps team IDs to team data. */
|
||||
private TeamData[] map = new TeamData[256];
|
||||
/** Active teams. */
|
||||
private Array<TeamData> active = new Array<>();
|
||||
private Seq<TeamData> active = new Seq<>();
|
||||
|
||||
public Teams(){
|
||||
active.add(get(Team.crux));
|
||||
@@ -38,7 +38,7 @@ public class Teams{
|
||||
return Geometry.findClosest(x, y, get(team).cores);
|
||||
}
|
||||
|
||||
public Array<Team> enemiesOf(Team team){
|
||||
public Seq<Team> enemiesOf(Team team){
|
||||
return get(team).enemies;
|
||||
}
|
||||
|
||||
@@ -73,12 +73,12 @@ public class Teams{
|
||||
return map[Pack.u(team.id)];
|
||||
}
|
||||
|
||||
public Array<CoreEntity> playerCores(){
|
||||
public Seq<CoreEntity> playerCores(){
|
||||
return get(state.rules.defaultTeam).cores;
|
||||
}
|
||||
|
||||
/** Do not modify! */
|
||||
public Array<CoreEntity> cores(Team team){
|
||||
public Seq<CoreEntity> cores(Team team){
|
||||
return get(team).cores;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class Teams{
|
||||
}
|
||||
|
||||
/** Do not modify. */
|
||||
public Array<TeamData> getActive(){
|
||||
public Seq<TeamData> getActive(){
|
||||
active.removeAll(t -> !t.active());
|
||||
return active;
|
||||
}
|
||||
@@ -145,8 +145,8 @@ public class Teams{
|
||||
}
|
||||
|
||||
public class TeamData{
|
||||
public final Array<CoreEntity> cores = new Array<>();
|
||||
public final Array<Team> enemies = new Array<>();
|
||||
public final Seq<CoreEntity> cores = new Seq<>();
|
||||
public final Seq<Team> enemies = new Seq<>();
|
||||
public final Team team;
|
||||
public final BaseAI ai;
|
||||
public Queue<BlockPlan> blocks = new Queue<>();
|
||||
|
||||
@@ -195,7 +195,7 @@ public class Tutorial{
|
||||
|
||||
protected String line = "";
|
||||
protected final Func<String, String> text;
|
||||
protected Array<String> sentences;
|
||||
protected Seq<String> sentences;
|
||||
protected final Boolp done;
|
||||
|
||||
TutorialStage(Func<String, String> text, Boolp done){
|
||||
@@ -218,7 +218,7 @@ public class Tutorial{
|
||||
|
||||
void load(){
|
||||
this.line = Core.bundle.has("tutorial." + name() + ".mobile") && mobile ? "tutorial." + name() + ".mobile" : "tutorial." + name();
|
||||
this.sentences = Array.select(Core.bundle.get(line).split("\n"), s -> !s.isEmpty());
|
||||
this.sentences = Seq.select(Core.bundle.get(line).split("\n"), s -> !s.isEmpty());
|
||||
}
|
||||
|
||||
/** called every frame when this stage is active.*/
|
||||
|
||||
Reference in New Issue
Block a user