use of com.b3dgs.lionengine.game.Orientation in project lionengine by b3dgs.
the class CollisionConstraintConfig method imports.
/**
* Create the collision constraint data from node.
*
* @param node The node reference (must not be <code>null</code>).
* @return The collision constraint data.
* @throws LionEngineException If error when reading node.
*/
public static CollisionConstraint imports(Xml node) {
Check.notNull(node);
final CollisionConstraint constraint = new CollisionConstraint();
if (node.hasChild(NODE_CONSTRAINT)) {
for (final Xml current : node.getChildren(NODE_CONSTRAINT)) {
final Orientation orientation = Orientation.valueOf(current.readString(ATT_ORIENTATION));
final String group = current.readString(ATT_GROUP);
constraint.add(orientation, group);
}
}
return constraint;
}
use of com.b3dgs.lionengine.game.Orientation in project lionengine by b3dgs.
the class CollisionConstraintConfig method exports.
/**
* Export the collision constraint as a node.
*
* @param root The node root (must not be <code>null</code>).
* @param constraint The collision constraint to export (must not be <code>null</code>).
* @throws LionEngineException If error on writing.
*/
public static void exports(Xml root, CollisionConstraint constraint) {
Check.notNull(root);
Check.notNull(constraint);
for (final Entry<Orientation, Collection<String>> entry : constraint.getConstraints().entrySet()) {
final Orientation orientation = entry.getKey();
for (final String group : entry.getValue()) {
final Xml current = root.createChild(NODE_CONSTRAINT);
current.writeEnum(ATT_ORIENTATION, orientation);
current.writeString(ATT_GROUP, group);
}
}
}
use of com.b3dgs.lionengine.game.Orientation in project lionengine by b3dgs.
the class OrientableModel method pointTo.
@Override
public void pointTo(int dtx, int dty) {
final int tx = map.getInTileX(transformable);
final int ty = map.getInTileY(transformable);
final Orientation next = Orientation.get(tx, ty, dtx, dty);
if (next != null) {
orientation = next;
}
}
use of com.b3dgs.lionengine.game.Orientation in project lionengine by b3dgs.
the class CollisionConstraintConfig method imports.
/**
* Create the collision constraint data from node.
*
* @param node The node reference (must not be <code>null</code>).
* @return The collision constraint data.
* @throws LionEngineException If error when reading node.
*/
public static CollisionConstraint imports(XmlReader node) {
Check.notNull(node);
final CollisionConstraint constraint = new CollisionConstraint();
if (node.hasNode(NODE_CONSTRAINT)) {
final Collection<XmlReader> children = node.getChildren(NODE_CONSTRAINT);
for (final XmlReader current : children) {
final Orientation orientation = current.getEnum(Orientation.class, ATT_ORIENTATION);
final String group = current.getString(ATT_GROUP);
constraint.add(orientation, group);
}
children.clear();
}
return constraint;
}
Aggregations