Fixed replacement of preset sectors in JSON
This commit is contained in:
@@ -680,23 +680,6 @@ public class SerpuloTechTree{
|
|||||||
), () -> {
|
), () -> {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//TODO: removed for now
|
|
||||||
/*node(polarAerodrome, Seq.with(
|
|
||||||
new SectorComplete(fungalPass),
|
|
||||||
new SectorComplete(desolateRift),
|
|
||||||
new SectorComplete(overgrowth),
|
|
||||||
new Research(multiplicativeReconstructor),
|
|
||||||
new Research(zenith),
|
|
||||||
new Research(swarmer),
|
|
||||||
new Research(cyclone),
|
|
||||||
new Research(blastDrill),
|
|
||||||
new Research(blastDrill),
|
|
||||||
new Research(massDriver)
|
|
||||||
), () -> {
|
|
||||||
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -695,17 +695,29 @@ public class ContentParser{
|
|||||||
return locate(ContentType.sector, name);
|
return locate(ContentType.sector, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!value.has("sector") || !value.get("sector").isNumber()) throw new RuntimeException("SectorPresets must have a sector number.");
|
SectorPreset preset;
|
||||||
|
SectorPreset found = locate(ContentType.sector, name);
|
||||||
|
|
||||||
SectorPreset out = new SectorPreset(mod + "-" + name, currentMod);
|
if(found != null){
|
||||||
|
preset = found;
|
||||||
|
}else{
|
||||||
|
if(!value.has("sector") || !value.get("sector").isNumber()) throw new RuntimeException("SectorPresets must have a sector number.");
|
||||||
|
|
||||||
currentContent = out;
|
preset = new SectorPreset(mod + "-" + name, currentMod);
|
||||||
|
}
|
||||||
|
|
||||||
|
currentContent = preset;
|
||||||
read(() -> {
|
read(() -> {
|
||||||
Planet planet = locate(ContentType.planet, value.getString("planet", "serpulo"));
|
Planet planet = preset.planet == null ? Planets.serpulo : preset.planet;
|
||||||
|
if(value.has("planet")){
|
||||||
|
planet = locate(ContentType.planet, value.getString("planet", "serpulo"));
|
||||||
|
|
||||||
if(planet == null) throw new RuntimeException("Planet '" + value.getString("planet") + "' not found.");
|
if(planet == null) throw new RuntimeException("Planet '" + value.getString("planet") + "' not found.");
|
||||||
|
}
|
||||||
|
|
||||||
out.initialize(planet, value.getInt("sector", 0));
|
if(value.has("sector")){
|
||||||
|
preset.initialize(planet, value.getInt("sector", 0));
|
||||||
|
}
|
||||||
|
|
||||||
value.remove("sector");
|
value.remove("sector");
|
||||||
value.remove("planet");
|
value.remove("planet");
|
||||||
@@ -713,7 +725,7 @@ public class ContentParser{
|
|||||||
if(value.has("rules")){
|
if(value.has("rules")){
|
||||||
JsonValue r = value.remove("rules");
|
JsonValue r = value.remove("rules");
|
||||||
if(!r.isObject()) throw new RuntimeException("Rules must be an object!");
|
if(!r.isObject()) throw new RuntimeException("Rules must be an object!");
|
||||||
out.rules = rules -> {
|
preset.rules = rules -> {
|
||||||
try{
|
try{
|
||||||
//Use standard JSON, this is not content-parser relevant
|
//Use standard JSON, this is not content-parser relevant
|
||||||
JsonIO.json.readFields(rules, r);
|
JsonIO.json.readFields(rules, r);
|
||||||
@@ -723,9 +735,9 @@ public class ContentParser{
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
readFields(out, value);
|
readFields(preset, value);
|
||||||
});
|
});
|
||||||
return out;
|
return preset;
|
||||||
},
|
},
|
||||||
ContentType.planet, (TypeParser<Planet>)(mod, name, value) -> {
|
ContentType.planet, (TypeParser<Planet>)(mod, name, value) -> {
|
||||||
if(value.isString()) return locate(ContentType.planet, name);
|
if(value.isString()) return locate(ContentType.planet, name);
|
||||||
|
|||||||
Reference in New Issue
Block a user