use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class TransitionsConfig method exports.
/**
* Export all transitions to media.
*
* @param media The export media output (must not be <code>null</code>).
* @param transitions The transitions reference (must not be <code>null</code>).
* @throws LionEngineException If error on export.
*/
public static void exports(Media media, Map<Transition, Collection<Integer>> transitions) {
Check.notNull(media);
Check.notNull(transitions);
final Xml nodeTransitions = new Xml(NODE_TRANSITIONS);
for (final Map.Entry<Transition, Collection<Integer>> entry : transitions.entrySet()) {
final Transition transition = entry.getKey();
final Xml nodeTransition = nodeTransitions.createChild(NODE_TRANSITION);
nodeTransition.writeEnum(ATTRIBUTE_TRANSITION_TYPE, transition.getType());
nodeTransition.writeString(ATTRIBUTE_GROUP_IN, transition.getIn());
nodeTransition.writeString(ATTRIBUTE_GROUP_OUT, transition.getOut());
exportTiles(nodeTransition, entry.getValue());
}
nodeTransitions.save(media);
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CircuitsConfig method exports.
/**
* Export all circuits to an XML file.
*
* @param media The export output (must not be <code>null</code>).
* @param circuits The circuits reference (must not be <code>null</code>).
* @throws LionEngineException If error on export.
*/
public static void exports(Media media, Map<Circuit, Collection<Integer>> circuits) {
Check.notNull(media);
Check.notNull(circuits);
final Xml nodeCircuits = new Xml(NODE_CIRCUITS);
for (final Map.Entry<Circuit, Collection<Integer>> entry : circuits.entrySet()) {
final Circuit circuit = entry.getKey();
final Xml nodeCircuit = nodeCircuits.createChild(NODE_CIRCUIT);
nodeCircuit.writeEnum(ATT_CIRCUIT_TYPE, circuit.getType());
nodeCircuit.writeString(ATT_GROUP_IN, circuit.getIn());
nodeCircuit.writeString(ATT_GROUP_OUT, circuit.getOut());
exportTiles(nodeCircuit, entry.getValue());
}
nodeCircuits.save(media);
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class MapTileCollisionModel method saveCollisions.
@Override
public void saveCollisions() {
final Media formulasConfig = loader.getFormulasConfig();
if (formulasConfig != null) {
final Xml formulasRoot = new Xml(CollisionFormulaConfig.NODE_FORMULAS);
for (final CollisionFormula formula : getCollisionFormulas()) {
CollisionFormulaConfig.exports(formulasRoot, formula);
}
formulasRoot.save(formulasConfig);
}
final Media groupsConfig = loader.getCollisionsConfig();
if (groupsConfig != null) {
final Xml groupsNode = new Xml(CollisionGroupConfig.NODE_COLLISIONS);
for (final CollisionGroup group : getCollisionGroups()) {
CollisionGroupConfig.exports(groupsNode, group);
}
groupsNode.save(groupsConfig);
}
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class MapTileCollisionLoader method loadCollisionGroups.
/**
* Load the collision groups. All previous groups will be cleared.
*
* @param mapCollision The map tile collision owner.
* @param groupsConfig The configuration collision groups file.
*/
private void loadCollisionGroups(MapTileCollision mapCollision, Media groupsConfig) {
this.groupsConfig = groupsConfig;
final Xml nodeGroups = new Xml(groupsConfig);
final CollisionGroupConfig config = CollisionGroupConfig.imports(nodeGroups, mapCollision);
loadCollisionGroups(config);
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class PathfindableConfig method exportPathData.
/**
* Create a path data from its node.
*
* @param data The path data (must not be <code>null</code>).
* @return The path data node.
*/
public static Xml exportPathData(PathData data) {
Check.notNull(data);
final Xml node = new Xml(NODE_PATH);
node.writeString(ATT_CATEGORY, data.getName());
node.writeDouble(ATT_COST, data.getCost());
node.writeBoolean(ATT_BLOCK, data.isBlocking());
exportAllowedMovements(node, data.getAllowedMovements());
return node;
}
Aggregations