private boolean canHitTarget(Coordinate c) { if (x() != c.x() && y() != c.y()) { // Nicht in einer Linie. return false; } List<Coordinate> path = new ProjectileBresenham(getActiveWeapon().getRange()).getPartialPath(world(), pos(), c); return path.get(path.size() - 1).equals(c); }
/** * Returns true if the given {@code Coordinate} location is inside the bounds of the {@code * World}. * * @param pos the location on the {@code World} being queried * @return true if pos is inside the bounds of the {@code World} */ public final boolean insideBounds(Coordinate pos) { return insideBounds(pos.x(), pos.y()); }
/** * Gets a randomly chosen open tile on the {@code World} within the given bounds. If after 100 * randomly selected tiles are closed, then each tile will be checked and the first open tile * found is returned. If the entire {@code World} is closed, null is returned. * * @param dice the random number generator used to randomly select tiles * @param topLeft the bounds upper-left most value * @param bottomRight the bounds bottom-right most value * @return a randomly chosen open tile */ public final Coordinate getOpenTile(Dice dice, Coordinate topLeft, Coordinate bottomRight) { Guard.argumentsAreNotNull(topLeft, bottomRight); return getOpenTile(dice, topLeft.x(), topLeft.y(), bottomRight.x(), bottomRight.y()); }
/** * Sets the face and passable value of the tile at the specified {@code Coordinate}. * * @param face the new face of the tile * @param passable the new passable value of the tile * @param coord the value of the position being updated */ public final void setTile(ColoredChar face, boolean passable, Coordinate coord) { Guard.argumentIsNotNull(coord); setTile(face, passable, coord.x(), coord.y()); }
/** * Returns true if the tile at the provided {@code Coordinate} is passable. * * @param coord the value of the position being queried * @return true if the tile at the given {@code Coordinate} */ public final boolean passableAt(Coordinate coord) { Guard.argumentIsNotNull(coord); return passableAt(coord.x(), coord.y()); }
/** * Returns the face of the tile at the provided coordinates. * * @param coord the value of the position being queried * @return the face of the tile at then given {@code Coordinate} */ public final ColoredChar tileAt(Coordinate coord) { Guard.argumentIsNotNull(coord); return tileAt(coord.x(), coord.y()); }
/** * Returns the face that should be drawn for the given location. * * @param pos the location being queried * @return the face that should be drawn for the given location. */ public final ColoredChar look(Coordinate pos) { Guard.argumentIsNotNull(pos); return look(pos.x(), pos.y()); }
/** * Returns every tile that is visible at a given location, ordered such that the tile with highest * priority (the tile returned by look) is first, and the lowest priority is last. This last tile * will be the face of the actual tile itself. Note that any actor which has a null face will not * be included. * * @param pos the location being queried * @return every tile that is visible at a given location */ public final List<ColoredChar> lookAll(Coordinate pos) { Guard.argumentIsNotNull(pos); return lookAll(pos.x(), pos.y()); }
/** * Returns a {@code Collection<T extends Actor>} of all {@code Actor} of the given class at the * given location. * * @param <T> the generic type of the class type to be returned * @param cls the {@code Class<T extends Actor>} of the {@code Actor} to be returned * @param pos the location being queried * @return a {@code Collection<T extends Actor>} of all {@code Actor} of the given class located * at (x, y) */ public final <T extends Actor> Collection<T> getActorsAt(Class<T> cls, Coordinate pos) { Guard.argumentIsNotNull(pos); return getActorsAt(cls, pos.x(), pos.y()); }
/** * Adds an {@code Actor} to the {@code World} at the specified location. * * @param actor the {@code World} being added * @param coord the location of the {@code Actor} */ public final void addActor(Actor actor, Coordinate coord) { Guard.argumentIsNotNull(coord); addActor(actor, coord.x(), coord.y()); }