AmmoType refactoring
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package mindustry.mod;
|
||||
|
||||
import arc.struct.*;
|
||||
import mindustry.type.ammo.*;
|
||||
|
||||
/** Generated class. Maps simple class names to concrete classes. For use in JSON mods. */
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ClassMap{
|
||||
@@ -52,9 +54,8 @@ public class ClassMap{
|
||||
classes.put("Research", mindustry.game.Objectives.Research.class);
|
||||
classes.put("SectorComplete", mindustry.game.Objectives.SectorComplete.class);
|
||||
classes.put("AmmoType", mindustry.type.AmmoType.class);
|
||||
classes.put("AmmoTypes", mindustry.type.AmmoTypes.class);
|
||||
classes.put("ItemAmmoType", mindustry.type.AmmoTypes.ItemAmmoType.class);
|
||||
classes.put("PowerAmmoType", mindustry.type.AmmoTypes.PowerAmmoType.class);
|
||||
classes.put("ItemAmmoType", ItemAmmoType.class);
|
||||
classes.put("PowerAmmoType", PowerAmmoType.class);
|
||||
classes.put("Category", mindustry.type.Category.class);
|
||||
classes.put("ErrorContent", mindustry.type.ErrorContent.class);
|
||||
classes.put("Item", mindustry.type.Item.class);
|
||||
|
||||
@@ -29,7 +29,7 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.mod.Mods.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.type.AmmoTypes.*;
|
||||
import mindustry.type.ammo.*;
|
||||
import mindustry.type.weather.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.units.*;
|
||||
@@ -97,9 +97,12 @@ public class ContentParser{
|
||||
return result;
|
||||
});
|
||||
put(AmmoType.class, (type, data) -> {
|
||||
if(data.isString()){
|
||||
return field(AmmoTypes.class, data);
|
||||
}
|
||||
//string -> item
|
||||
//if liquid ammo support is added, this should scan for liquids as well
|
||||
if(data.isString()) return find(ContentType.item, data.asString());
|
||||
//number -> power
|
||||
if(data.isNumber()) return new PowerAmmoType(data.asFloat());
|
||||
|
||||
var bc = resolve(data.getString("type", ""), ItemAmmoType.class);
|
||||
data.remove("type");
|
||||
AmmoType result = make(bc);
|
||||
@@ -357,16 +360,6 @@ public class ContentParser{
|
||||
if(!value.has("sector") || !value.get("sector").isNumber()) throw new RuntimeException("SectorPresets must have a sector number.");
|
||||
|
||||
return new SectorPreset(name, locate(ContentType.planet, value.getString("planet", "serpulo")), value.getInt("sector"));
|
||||
},
|
||||
ContentType.ammo, (TypeParser<AmmoType>)(mod, name, value) -> {
|
||||
if(value.isString()){
|
||||
return (AmmoType)field(AmmoTypes.class, value.asString());
|
||||
}
|
||||
|
||||
AmmoType item = make(resolve(value.getString("type", null), ItemAmmoType.class));
|
||||
currentContent = item;
|
||||
read(() -> readFields(item, value));
|
||||
return item;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user