use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionFormulaConfig method exports.
/**
* Export the current formula data to the formula node.
*
* @param root The root node (must not be <code>null</code>).
* @param formula The formula reference (must not be <code>null</code>).
* @throws LionEngineException If error on writing.
*/
public static void exports(Xml root, CollisionFormula formula) {
Check.notNull(root);
Check.notNull(formula);
final Xml node = root.createChild(NODE_FORMULA);
node.writeString(ATT_NAME, formula.getName());
CollisionRangeConfig.exports(node, formula.getRange());
CollisionFunctionConfig.exports(node, formula.getFunction());
CollisionConstraintConfig.exports(node, formula.getConstraint());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionGroupConfig method imports.
/**
* Create the collision group data from node (should only be used to display names, as real content is
* <code>null</code>, mainly UI specific to not have dependency on {@link MapTileCollision}).
*
* @param config The tile collision groups descriptor (must not be <code>null</code>).
* @return The collisions group data.
* @throws LionEngineException If unable to read node.
*/
public static CollisionGroupConfig imports(Media config) {
final Xml root = new Xml(config);
final Collection<XmlReader> childrenCollision = root.getChildren(NODE_COLLISION);
final Map<String, CollisionGroup> groups = new HashMap<>(childrenCollision.size());
for (final XmlReader node : childrenCollision) {
final Collection<XmlReader> childrenFormula = node.getChildren(CollisionFormulaConfig.NODE_FORMULA);
final Collection<CollisionFormula> formulas = new ArrayList<>(childrenFormula.size());
for (final XmlReader formula : childrenFormula) {
final String formulaName = formula.getText();
formulas.add(new CollisionFormula(formulaName, null, null, null));
}
childrenFormula.clear();
final String groupName = node.getString(ATT_GROUP);
final CollisionGroup collision = new CollisionGroup(groupName, formulas);
groups.put(groupName, collision);
}
childrenCollision.clear();
return new CollisionGroupConfig(groups);
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionGroupConfig method exports.
/**
* Export the collision group data as a node.
*
* @param root The node root (must not be <code>null</code>).
* @param group The collision group to export (must not be <code>null</code>).
* @throws LionEngineException If error on writing.
*/
public static void exports(Xml root, CollisionGroup group) {
Check.notNull(root);
Check.notNull(group);
final Xml node = root.createChild(NODE_COLLISION);
node.writeString(ATT_GROUP, group.getName());
for (final CollisionFormula formula : group.getFormulas()) {
final Xml nodeFormula = node.createChild(CollisionFormulaConfig.NODE_FORMULA);
nodeFormula.setText(formula.getName());
}
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionRangeConfig method exports.
/**
* Export the collision range as a node.
*
* @param root The node root (must not be <code>null</code>).
* @param range The collision range to export (must not be <code>null</code>).
* @throws LionEngineException If error on writing.
*/
public static void exports(Xml root, CollisionRange range) {
Check.notNull(root);
Check.notNull(range);
final Xml node = root.createChild(NODE_RANGE);
node.writeEnum(ATT_AXIS, range.getOutput());
node.writeInteger(ATT_MIN_X, range.getMinX());
node.writeInteger(ATT_MIN_Y, range.getMinY());
node.writeInteger(ATT_MAX_X, range.getMaxX());
node.writeInteger(ATT_MAX_Y, range.getMaxY());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class ExtractableConfig method exports.
/**
* Exports the node from config.
*
* @param config The config reference (must not be <code>null</code>).
* @return The extractable node.
* @throws LionEngineException If unable to read node.
*/
public static Xml exports(ExtractableConfig config) {
Check.notNull(config);
final Xml node = new Xml(NODE_EXTRACTABLE);
node.writeString(ATT_TYPE, config.getType());
node.writeInteger(ATT_QUANTITY, config.getQuantity());
return node;
}
Aggregations