New hint tutorial system (unfinished!)
This commit is contained in:
@@ -37,6 +37,7 @@ import mindustry.world.draw.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ContentParser{
|
||||
@@ -267,7 +268,13 @@ public class ContentParser{
|
||||
UnitType unit;
|
||||
if(locate(ContentType.unit, name) == null){
|
||||
unit = new UnitType(mod + "-" + name);
|
||||
unit.constructor = Reflect.cons(resolve(Strings.capitalize(getType(value)), "mindustry.gen"));
|
||||
var typeVal = value.get("type");
|
||||
|
||||
if(typeVal != null && !typeVal.isString()){
|
||||
throw new RuntimeException("Unit '" + name + "' has an incorrect type. Types must be strings.");
|
||||
}
|
||||
|
||||
unit.constructor = unitType(typeVal);
|
||||
}else{
|
||||
unit = locate(ContentType.unit, name);
|
||||
}
|
||||
@@ -337,6 +344,18 @@ public class ContentParser{
|
||||
//ContentType.sector, parser(ContentType.sector, SectorPreset::new)
|
||||
);
|
||||
|
||||
private Prov<Unit> unitType(JsonValue value){
|
||||
if(value == null) return UnitEntity::create;
|
||||
return switch(value.asString()){
|
||||
case "flying" -> UnitEntity::create;
|
||||
case "mech" -> MechUnit::create;
|
||||
case "legs" -> LegsUnit::create;
|
||||
case "naval" -> UnitWaterMove::create;
|
||||
case "payload" -> PayloadUnit::create;
|
||||
default -> throw new RuntimeException("Invalid unit type: '" + value + "'. Must be 'flying/mech/legs/naval/payload'.");
|
||||
};
|
||||
}
|
||||
|
||||
private String getString(JsonValue value, String key){
|
||||
if(value.has(key)){
|
||||
return value.getString(key);
|
||||
|
||||
Reference in New Issue
Block a user