Turn logic / Cross-sector production / Pad tweaks

This commit is contained in:
Anuken
2020-05-15 11:03:21 -04:00
parent 603cb4295a
commit b68e0a8562
16 changed files with 188 additions and 39 deletions

View File

@@ -3,6 +3,7 @@ package mindustry.io;
import arc.struct.*;
import mindustry.game.*;
import mindustry.maps.*;
import mindustry.type.*;
import static mindustry.Vars.maps;
@@ -16,8 +17,11 @@ public class SaveMeta{
public Rules rules;
public StringMap tags;
public String[] mods;
/** These are in items/second. */
public ObjectFloatMap<Item> productionRates;
public boolean hasProduction;
public SaveMeta(int version, long timestamp, long timePlayed, int build, String map, int wave, Rules rules, StringMap tags){
public SaveMeta(int version, long timestamp, long timePlayed, int build, String map, int wave, Rules rules, ObjectFloatMap<Item> productionRates, StringMap tags){
this.version = version;
this.build = build;
this.timestamp = timestamp;
@@ -27,5 +31,8 @@ public class SaveMeta{
this.rules = rules;
this.tags = tags;
this.mods = JsonIO.read(String[].class, tags.get("mods", "[]"));
this.productionRates = productionRates;
productionRates.each(e -> hasProduction |= e.value > 0.001f);
}
}

View File

@@ -31,7 +31,17 @@ public abstract class SaveVersion extends SaveFileReader{
public SaveMeta getMeta(DataInput stream) throws IOException{
stream.readInt(); //length of data, doesn't matter here
StringMap map = readStringMap(stream);
return new SaveMeta(map.getInt("version"), map.getLong("saved"), map.getLong("playtime"), map.getInt("build"), map.get("mapname"), map.getInt("wave"), JsonIO.read(Rules.class, map.get("rules", "{}")), map);
return new SaveMeta(
map.getInt("version"),
map.getLong("saved"),
map.getLong("playtime"),
map.getInt("build"),
map.get("mapname"),
map.getInt("wave"),
JsonIO.read(Rules.class, map.get("rules", "{}")),
JsonIO.read(Stats.class, map.get("stats", "{}")).productionRates(),
map
);
}
@Override