not so much an API request, but more of a suggestion to how game data json is loaded, and how it can be loaded in a more flexible way
when dealing with json loading for my own purposes, i came to the problem that i do not want to copypaste the
entire json object when i want to make a copy of it with only one or two parameters changed
as such i came up with a rather janky, but functional solution, that allows me to define a
"parent" key in that json, and on loading said object it will attempt to load also the parent, and inherit all the values not defined in the child, and then garandparent, etc etc, until it reaches the very base definition of that type of object
Spoiler
public static JSONObject getMergedJSONInheritParameters(JSONObject all, String key, String parentKey, String defaultParentID){
JSONObject j1 = null;
try {
j1 = all.getJSONObject(key);
String p1 = j1.optString(parentKey, defaultParentID);
while(true){
JSONObject j2 = all.getJSONObject(p1);
Iterator<String> kk = j2.sortedKeys();
while(kk.hasNext()){
String k1 = kk.next();
if(!j1.has(k1)){
j1.put(k1,j2.get(k1));
}
}
if(p1.equals(defaultParentID))break;
p1 = j2.optString(parentKey);
}
}catch (Exception ex){
throw new RuntimeException("error parsing "+key, ex);
}
return j1;
}
so my request is, implement some similar functionality for loading some vanilla data files, in particular ships and weapons, but customEntities would be helpful too.
by adding a special `"extends"` field/column to those json/csv files
this will probably have some impact on loading time, not sure how much. but this will simplify modding and core game development by some amount, in particular things like "_fighter" versions of the weapons, instead of having a full set of all values defined, would have only one or two values, and the rest would be inherited from the parent data.