use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class PathfindableConfigTest method testNoNode.
/**
* Test without node.
*/
@Test
void testNoNode() {
final Xml root = new Xml("test");
final Media media = Medias.create("pathfindable.xml");
root.save(media);
assertTrue(PathfindableConfig.imports(new Configurer(media)).isEmpty());
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class FovableConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final Xml root = new Xml("test");
root.add(FovableConfig.exports(1));
final Media media = Medias.create("Object.xml");
root.save(media);
assertEquals(1, FovableConfig.imports(new Xml(media)));
assertEquals(1, FovableConfig.imports(new Configurer(media)));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class FeaturableConfig method exportClass.
/**
* Export the featurable node from class data.
*
* @param clazz The class name (must not be <code>null</code>).
* @return The class node.
* @throws LionEngineException If unable to export node.
*/
public static Xml exportClass(String clazz) {
Check.notNull(clazz);
final Xml node = new Xml(ATT_CLASS);
node.setText(clazz);
return node;
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class ForceConfig method exports.
/**
* Export the force node from data.
*
* @param force The force reference (must not be <code>null</code>).
* @return The force data.
* @throws LionEngineException If unable to read node.
*/
public static Xml exports(Force force) {
Check.notNull(force);
final Xml node = new Xml(NODE_FORCE);
node.writeDouble(ATT_VX, force.getDirectionHorizontal());
node.writeDouble(ATT_VY, force.getDirectionVertical());
node.writeDouble(ATT_VELOCITY, force.getVelocity());
node.writeDouble(ATT_SENSIBILITY, force.getSensibility());
return node;
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class ActionConfig method exports.
/**
* Export the action node from data.
*
* @param config The config reference (must not be <code>null</code>).
* @return The action node.
* @throws LionEngineException If unable to save.
*/
public static Xml exports(ActionConfig config) {
Check.notNull(config);
final Xml nodeAction = new Xml(NODE_ACTION);
nodeAction.writeString(ATT_NAME, config.getName());
nodeAction.writeString(ATT_DESCRIPTION, config.getDescription());
nodeAction.writeInteger(ATT_X, config.getX());
nodeAction.writeInteger(ATT_Y, config.getY());
nodeAction.writeInteger(ATT_WIDTH, config.getWidth());
nodeAction.writeInteger(ATT_HEIGHT, config.getHeight());
return nodeAction;
}
Aggregations