use of com.b3dgs.lionengine.XmlReader in project lionengine by b3dgs.
the class SizeConfig method imports.
/**
* Import the size data from configurer.
*
* @param root The root reference (must not be <code>null</code>).
* @return The size data.
* @throws LionEngineException If unable to read node.
*/
public static SizeConfig imports(XmlReader root) {
Check.notNull(root);
final XmlReader node = root.getChild(NODE_SIZE);
final int width = node.getInteger(ATT_WIDTH);
final int height = node.getInteger(ATT_HEIGHT);
return new SizeConfig(width, height);
}
use of com.b3dgs.lionengine.XmlReader in project lionengine by b3dgs.
the class ActionsConfig method imports.
/**
* Create the action data from node.
*
* @param root The root reference (must not be <code>null</code>).
* @param id The id supplier to handle unique instance if needed (must not be <code>null</code>).
* @return The allowed actions.
* @throws LionEngineException If unable to read node.
*/
public static List<ActionRef> imports(XmlReader root, Function<Class<? extends Feature>, Feature> id) {
Check.notNull(root);
if (!root.hasNode(NODE_ACTIONS)) {
return Collections.emptyList();
}
final XmlReader node = root.getChild(NODE_ACTIONS);
return getRefs(node, id);
}
use of com.b3dgs.lionengine.XmlReader in project lionengine by b3dgs.
the class ActionsConfig method getRefs.
/**
* Get all actions and their references.
*
* @param node The current node to check (must not be <code>null</code>).
* @param id The id supplier to handle unique instance if needed (must not be <code>null</code>).
* @return The actions found.
*/
private static List<ActionRef> getRefs(XmlReader node, Function<Class<? extends Feature>, Feature> id) {
final Collection<XmlReader> children = node.getChildren(NODE_ACTION_REF);
final List<ActionRef> actions = new ArrayList<>(children.size());
for (final XmlReader action : children) {
final String path = action.getString(ATT_PATH);
final boolean cancel = action.getBoolean(false, ATT_CANCEL);
final boolean unique = action.getBoolean(false, ATT_UNIQUE);
actions.add(new ActionRef(path, cancel, getRefs(action, id), unique ? id : null));
}
children.clear();
return actions;
}
use of com.b3dgs.lionengine.XmlReader in project lionengine by b3dgs.
the class AttackerConfig method imports.
/**
* Imports the config from node.
*
* @param root The root reference (must not be <code>null</code>).
* @return The attacker data.
* @throws LionEngineException If unable to read node or invalid integer.
*/
public static AttackerConfig imports(XmlReader root) {
Check.notNull(root);
final XmlReader node = root.getChild(NODE_ATTACKER);
final int delay = node.getInteger(0, ATT_DELAY);
final int distanceMin = node.getInteger(0, ATT_DISTANCE_MIN);
final int distanceMax = node.getInteger(0, ATT_DISTANCE_MAX);
final int damagesMin = node.getInteger(0, ATT_DAMAGES_MIN);
final int damagesMax = node.getInteger(0, ATT_DAMAGES_MAX);
return new AttackerConfig(delay, distanceMin, distanceMax, damagesMin, damagesMax);
}
use of com.b3dgs.lionengine.XmlReader in project lionengine by b3dgs.
the class LayerableConfig method imports.
/**
* Imports the layerable config from node.
*
* @param root The root reference (must not be <code>null</code>).
* @return The layerable data.
* @throws LionEngineException If unable to read node or invalid integer.
*/
public static LayerableConfig imports(XmlReader root) {
Check.notNull(root);
final XmlReader node = root.getChild(NODE_LAYERABLE);
final int layerRefresh = node.getInteger(ATT_REFRESH);
final int layerDisplay = node.getInteger(ATT_DISPLAY);
return new LayerableConfig(layerRefresh, layerDisplay);
}
Aggregations