use of com.b3dgs.lionengine.io.Xml 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>).
* @return The allowed actions.
* @throws LionEngineException If unable to read node.
*/
public static List<ActionRef> imports(Xml root) {
Check.notNull(root);
if (!root.hasChild(NODE_ACTIONS)) {
return Collections.emptyList();
}
final Xml node = root.getChild(NODE_ACTIONS);
return getRefs(node);
}
use of com.b3dgs.lionengine.io.Xml 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>).
* @return The actions found.
*/
private static List<ActionRef> getRefs(Xml node) {
final Collection<Xml> children = node.getChildren(NODE_ACTION);
final List<ActionRef> actions = new ArrayList<>(children.size());
for (final Xml action : children) {
final String path = action.readString(ATT_PATH);
final boolean cancel = action.readBoolean(false, ATT_CANCEL);
actions.add(new ActionRef(path, cancel, getRefs(action)));
}
return actions;
}
use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class ForceConfig method imports.
/**
* Create the force data from node.
*
* @param root The root reference (must not be <code>null</code>).
* @return The force data.
* @throws LionEngineException If unable to read node.
*/
public static Force imports(Xml root) {
Check.notNull(root);
final Xml node = root.getChild(NODE_FORCE);
final Force force = new Force(node.readDouble(ATT_VX), node.readDouble(ATT_VY));
force.setVelocity(node.readDouble(0.0, ATT_VELOCITY));
force.setSensibility(node.readDouble(0.0, ATT_SENSIBILITY));
return force;
}
use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class SurfaceConfig method imports.
/**
* Create the surface data from node.
*
* @param root The root reference (must not be <code>null</code>).
* @return The surface data.
* @throws LionEngineException If unable to read node.
*/
public static SurfaceConfig imports(Xml root) {
Check.notNull(root);
final Xml node = root.getChild(NODE_SURFACE);
final String surface = node.readString(ATT_IMAGE);
final String icon = node.readString(null, ATT_ICON);
return new SurfaceConfig(surface, icon);
}
use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class FeaturableModel method getFeatures.
/**
* Get all available features.
* Default constructor of each feature must be available or with {@link Setup} as single parameter.
*
* @param services The services reference.
* @param setup The setup reference.
* @return The available features.
* @throws LionEngineException If invalid class.
*/
private static List<Feature> getFeatures(Services services, Setup setup) {
final Collection<Xml> children = setup.getRoot().getChildren(FeaturableConfig.NODE_FEATURE);
final List<Feature> features = new ArrayList<>(children.size());
for (final Xml featureNode : children) {
final String className = featureNode.getText();
final Feature feature;
try {
final Class<? extends Feature> clazz = getClass(className);
feature = UtilReflection.createReduce(clazz, services, setup);
} catch (final NoSuchMethodException exception) {
throw new LionEngineException(exception);
}
features.add(feature);
}
return features;
}
Aggregations