use of pl.themolka.arcade.leak.Liquid in project Arcade2 by ShootGame.
the class CoreFactory method parseCoreXml.
public Core parseCoreXml(LeakGame game, Element xml, Core core) {
String paramLiquid = xml.getAttributeValue("liquid");
String paramMaterial = xml.getAttributeValue("material");
String paramDetectorLevel = xml.getAttributeValue("detector-level");
// liquid
Liquid liquid = Core.DEFAULT_LIQUID;
if (paramLiquid != null && !paramLiquid.isEmpty()) {
Liquid type = Liquid.valueOf(XMLParser.parseEnumValue(paramLiquid));
if (type != null) {
liquid = type;
}
}
// material
List<Material> material = Collections.singletonList(Core.DEFAULT_MATERIAL);
if (paramMaterial != null) {
material = parseArray(new Attribute("material", paramMaterial), Core.DEFAULT_MATERIAL);
}
// detector
int detectorLevel = Core.DEFAULT_DETECTOR_LEVEL;
if (paramDetectorLevel != null && !paramDetectorLevel.isEmpty()) {
try {
detectorLevel = Integer.parseInt(paramDetectorLevel);
} catch (NumberFormatException ignored) {
}
}
// region
Region region = XMLRegion.parseUnion(game.getGame(), xml.getChild("region"));
if (region == null) {
return null;
}
// setup
core.setMaterial(material);
core.build(liquid, region, detectorLevel);
return core;
}