use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionCategoryConfig method exports.
/**
* Export the collision category data as a node.
*
* @param root The node root (must not be <code>null</code>).
* @param category The collision category to export (must not be <code>null</code>).
* @throws LionEngineException If error on writing.
*/
public static void exports(Xml root, CollisionCategory category) {
Check.notNull(root);
Check.notNull(category);
final Xml categories;
if (root.hasNode(NODE_CATEGORIES)) {
categories = root.getChildXml(NODE_CATEGORIES);
} else {
categories = root.createChild(NODE_CATEGORIES);
}
final Xml node = categories.createChild(NODE_CATEGORY);
node.writeString(ATT_NAME, category.getName());
node.writeEnum(ATT_AXIS, category.getAxis());
node.writeInteger(ATT_X, category.getOffsetX());
node.writeInteger(ATT_Y, category.getOffsetY());
node.writeBoolean(ATT_GLUE, category.isGlue());
for (final CollisionGroup group : category.getGroups()) {
final Xml groupNode = node.createChild(TileGroupsConfig.NODE_GROUP);
groupNode.setText(group.getName());
}
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionConstraintConfig method exports.
/**
* Export the collision constraint as a node.
*
* @param root The node root (must not be <code>null</code>).
* @param constraint The collision constraint to export (must not be <code>null</code>).
* @throws LionEngineException If error on writing.
*/
public static void exports(Xml root, CollisionConstraint constraint) {
Check.notNull(root);
Check.notNull(constraint);
for (final Entry<Orientation, Collection<String>> entry : constraint.getConstraints().entrySet()) {
final Orientation orientation = entry.getKey();
for (final String group : entry.getValue()) {
final Xml current = root.createChild(NODE_CONSTRAINT);
current.writeEnum(ATT_ORIENTATION, orientation);
current.writeString(ATT_GROUP, group);
}
}
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionFormulaConfig method remove.
/**
* Remove the formula node.
*
* @param root The root node (must not be <code>null</code>).
* @param formula The formula name to remove (must not be <code>null</code>).
* @throws LionEngineException If invalid argument.
*/
public static void remove(Xml root, String formula) {
Check.notNull(root);
Check.notNull(formula);
final Collection<Xml> children = root.getChildrenXml(NODE_FORMULA);
for (final Xml node : children) {
if (node.getString(ATT_NAME).equals(formula)) {
root.removeChild(node);
}
}
children.clear();
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionFunctionConfig method exports.
/**
* Export the collision function data as a node.
*
* @param root The node root (must not be <code>null</code>).
* @param function The collision function to export (must not be <code>null</code>).
* @throws LionEngineException If error on writing.
*/
public static void exports(Xml root, CollisionFunction function) {
Check.notNull(root);
Check.notNull(function);
final Xml node = root.createChild(FUNCTION);
if (function instanceof CollisionFunctionLinear) {
final CollisionFunctionLinear linear = (CollisionFunctionLinear) function;
node.writeEnum(TYPE, CollisionFunctionType.LINEAR);
node.writeDouble(A, linear.getA());
node.writeDouble(B, linear.getB());
} else {
node.writeEnum(TYPE, function.getType());
}
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionGroupConfig method remove.
/**
* Remove the group node.
*
* @param root The root node (must not be <code>null</code>).
* @param group The group name to remove (must not be <code>null</code>).
* @throws LionEngineException If invalid argument.
*/
public static void remove(Xml root, String group) {
Check.notNull(root);
Check.notNull(group);
final Collection<Xml> children = root.getChildrenXml(NODE_COLLISION);
for (final Xml node : children) {
if (node.getString(ATT_GROUP).equals(group)) {
root.removeChild(node);
}
}
children.clear();
}
Aggregations