Bugfix
This commit is contained in:
@@ -317,9 +317,9 @@ public class TechTree implements ContentList{
|
|||||||
return node(block, () -> {});
|
return node(block, () -> {});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void create(Block parent, Block block){
|
public static TechNode create(Block parent, Block block){
|
||||||
TechNode.context = all.find(t -> t.block == parent);
|
TechNode.context = all.find(t -> t.block == parent);
|
||||||
node(block, () -> {});
|
return node(block, () -> {});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TechNode{
|
public static class TechNode{
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import io.anuke.arc.util.serialization.*;
|
|||||||
import io.anuke.arc.util.serialization.Json.*;
|
import io.anuke.arc.util.serialization.Json.*;
|
||||||
import io.anuke.mindustry.*;
|
import io.anuke.mindustry.*;
|
||||||
import io.anuke.mindustry.content.*;
|
import io.anuke.mindustry.content.*;
|
||||||
|
import io.anuke.mindustry.content.TechTree.*;
|
||||||
import io.anuke.mindustry.entities.Effects.*;
|
import io.anuke.mindustry.entities.Effects.*;
|
||||||
import io.anuke.mindustry.entities.bullet.*;
|
import io.anuke.mindustry.entities.bullet.*;
|
||||||
import io.anuke.mindustry.entities.type.*;
|
import io.anuke.mindustry.entities.type.*;
|
||||||
@@ -69,6 +70,7 @@ public class ContentParser{
|
|||||||
/** Stores things that need to be parsed fully, e.g. reading fields of content.
|
/** Stores things that need to be parsed fully, e.g. reading fields of content.
|
||||||
* This is done to accomodate binding of content names first.*/
|
* This is done to accomodate binding of content names first.*/
|
||||||
private Array<Runnable> reads = new Array<>();
|
private Array<Runnable> reads = new Array<>();
|
||||||
|
private Array<Runnable> postreads = new Array<>();
|
||||||
private LoadedMod currentMod;
|
private LoadedMod currentMod;
|
||||||
private Content currentContent;
|
private Content currentContent;
|
||||||
|
|
||||||
@@ -138,6 +140,15 @@ public class ContentParser{
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentContent = block;
|
currentContent = block;
|
||||||
|
|
||||||
|
String[] research = {null};
|
||||||
|
|
||||||
|
//add research tech node
|
||||||
|
if(value.has("research")){
|
||||||
|
research[0] = value.get("research").asString();
|
||||||
|
value.remove("research");
|
||||||
|
}
|
||||||
|
|
||||||
read(() -> {
|
read(() -> {
|
||||||
if(value.has("consumes")){
|
if(value.has("consumes")){
|
||||||
for(JsonValue child : value.get("consumes")){
|
for(JsonValue child : value.get("consumes")){
|
||||||
@@ -165,8 +176,16 @@ public class ContentParser{
|
|||||||
readFields(block, value, true);
|
readFields(block, value, true);
|
||||||
|
|
||||||
//add research tech node
|
//add research tech node
|
||||||
if(value.has("research")){
|
if(research[0] != null){
|
||||||
TechTree.create(find(ContentType.block, value.get("research").asString()), block);
|
Block parent = find(ContentType.block, research[0]);
|
||||||
|
TechNode baseNode = TechTree.create(parent, block);
|
||||||
|
|
||||||
|
postreads.add(() -> {
|
||||||
|
TechNode parnode = TechTree.all.find(t -> t.block == parent);
|
||||||
|
if(!parnode.children.contains(baseNode)){
|
||||||
|
parnode.children.add(baseNode);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//make block visible by default if there are requirements and no visibility set
|
//make block visible by default if there are requirements and no visibility set
|
||||||
@@ -266,6 +285,7 @@ public class ContentParser{
|
|||||||
public void finishParsing(){
|
public void finishParsing(){
|
||||||
try{
|
try{
|
||||||
reads.each(Runnable::run);
|
reads.each(Runnable::run);
|
||||||
|
postreads.each(Runnable::run);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
Vars.mods.handleError(new ModLoadException("Error occurred parsing content: " + currentContent, currentContent, e), currentMod);
|
Vars.mods.handleError(new ModLoadException("Error occurred parsing content: " + currentContent, currentContent, e), currentMod);
|
||||||
}
|
}
|
||||||
@@ -386,9 +406,7 @@ public class ContentParser{
|
|||||||
FieldMetadata metadata = fields.get(child.name().replace(" ", "_"));
|
FieldMetadata metadata = fields.get(child.name().replace(" ", "_"));
|
||||||
if(metadata == null){
|
if(metadata == null){
|
||||||
if(ignoreUnknownFields){
|
if(ignoreUnknownFields){
|
||||||
if(!child.name.equals("research")){
|
|
||||||
Log.err("{0}: Ignoring unknown field: " + child.name + " (" + type.getName() + ")", object);
|
Log.err("{0}: Ignoring unknown field: " + child.name + " (" + type.getName() + ")", object);
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}else{
|
}else{
|
||||||
SerializationException ex = new SerializationException("Field not found: " + child.name + " (" + type.getName() + ")");
|
SerializationException ex = new SerializationException("Field not found: " + child.name + " (" + type.getName() + ")");
|
||||||
|
|||||||
Reference in New Issue
Block a user