use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class BodyConfig method exports.
/**
* Create an XML node from a body.
*
* @param root The node root (must not be <code>null</code>).
* @param body The body reference (must not be <code>null</code>).
* @throws LionEngineException If invalid argument.
*/
public static void exports(Xml root, Body body) {
Check.notNull(root);
Check.notNull(body);
final Xml node = root.createChild(NODE_BODY);
node.writeDouble(ATT_GRAVITY, body.getGravity());
node.writeDouble(ATT_GRAVITY_MAX, body.getGravityMax());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class ProducibleConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final ProducibleConfig producible = new ProducibleConfig(1, 2, 3);
final Xml root = new Xml("test");
root.add(SizeConfig.exports(new SizeConfig(producible.getWidth(), producible.getHeight())));
root.add(ProducibleConfig.exports(producible));
final Media media = Medias.create("producible.xml");
root.save(media);
assertEquals(producible, ProducibleConfig.imports(new Xml(media)));
assertEquals(producible, ProducibleConfig.imports(new Setup(media)));
assertEquals(producible, ProducibleConfig.imports(new Configurer(media)));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class AttackerConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final AttackerConfig config = new AttackerConfig(1, 2, 3, 4, 5);
final Xml root = new Xml("test");
root.add(AttackerConfig.exports(config));
final Media media = Medias.create("Object.xml");
root.save(media);
assertEquals(config, AttackerConfig.imports(new Xml(media)));
assertEquals(config, AttackerConfig.imports(new Configurer(media)));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollidableConfigTest method testEmptyAccepted.
/**
* Test with empty accepted.
*/
@Test
void testEmptyAccepted() {
final Media media = Medias.create("Object.xml");
final Xml root = new Xml("test");
root.save(media);
final Services services = new Services();
services.add(new ViewerMock());
final Collidable collidable = new CollidableModel(services, new Setup(media));
collidable.setGroup(Integer.valueOf(1));
CollidableConfig.exports(root, collidable);
root.save(media);
final CollidableConfig config = CollidableConfig.imports(new Configurer(media));
assertEquals(Integer.valueOf(1), config.getGroup());
assertTrue(config.getAccepted().isEmpty());
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollidableConfigTest method testExport.
/**
* Test export.
*/
@Test
void testExport() {
final Media media = Medias.create("Object.xml");
final Xml root = new Xml("test");
root.save(media);
final Services services = new Services();
services.add(new ViewerMock());
final Collidable collidable = new CollidableModel(services, new Setup(media));
collidable.setGroup(Integer.valueOf(1));
collidable.addAccept(Integer.valueOf(2));
collidable.addAccept(Integer.valueOf(3));
CollidableConfig.exports(root, collidable);
root.save(media);
final CollidableConfig config = CollidableConfig.imports(new Configurer(media));
assertEquals(Integer.valueOf(1), config.getGroup());
assertIterableEquals(Arrays.asList(Integer.valueOf(2), Integer.valueOf(3)), config.getAccepted());
assertTrue(media.getFile().delete());
}
Aggregations