Tabnine Logo
IMapArea.stream
Code IndexAdd Tabnine to your IDE (free)

How to use
stream
method
in
jsettlers.common.map.shapes.IMapArea

Best Java code snippets using jsettlers.common.map.shapes.IMapArea.stream (Showing top 9 results out of 315)

origin: jsettlers/settlers-remake

  @Override
  public CoordinateStream stream() {
    return base.stream().filterBounds(width, height);
  }
}
origin: jsettlers/settlers-remake

  public CoordinateStream getAreaWithoutGround() {
    return area.stream().filter((x, y) -> !groundArea.contains(x, y));
  }
}
origin: jsettlers/settlers-remake

/**
 * Removes the tower at the given position from the grid.
 * 
 * @param pos
 *            The position of the tower.
 */
public void removeTowerAndFreeOccupiedArea(ShortPoint2D pos) {
  // get the tower object and the informations of it.
  PartitionOccupyingTower tower = occupyingTowers.removeAt(pos);
  if (tower == null) {
    return ;
  }
  // reduce the tower counter
  changeTowerCounter(tower.playerId, tower.area.stream(), -1);
  checkOtherTowersInArea(tower);
}
origin: jsettlers/settlers-remake

/**
 * Recalculates the tower counter for the given area. <br>
 * NOTE: The given area must completely belong to the given player!
 *
 * @param tower
 * @param tower
 * @param area
 */
private void recalculateTowerCounter(PartitionOccupyingTower tower, IMapArea area) {
  area.stream().forEach((x, y) -> towers[x + y * width] = 0);
  List<Tuple<Integer, PartitionOccupyingTower>> towersInRange = occupyingTowers.getTowersInRange(tower.position, tower.radius, currTower -> currTower.playerId == tower.playerId);
  stream(towersInRange)
      .forEach(currTower -> area.stream()
          .filter(currTower.e2.area::contains)
          .forEach((x, y) -> towers[x + y * width]++));
}
origin: jsettlers/settlers-remake

private void occupyAreaOfTower(PartitionOccupyingTower tower) {
  // set the tower counter of the groundArea to 0 => the ground area will be occupied
  tower.groundArea.stream().forEach((x, y) -> towers[x + y * width] = 0);
  // occupy the area for the new player
  occupyAreaByTower(tower.playerId, tower.area.stream(), tower.areaBorders);
  occupyingTowers.add(tower);
  // recalculate the tower counter for the ground area
  recalculateTowerCounter(tower, tower.groundArea);
}
origin: jsettlers/settlers-remake

/**
 * Changes the player of the tower at given position to the new player. After this operation, the given ground area will always be occupied by the new player.
 * 
 * @param towerPosition
 * @param newPlayerId
 * @return
 */
public CoordinateStream changePlayerOfTower(ShortPoint2D towerPosition, byte newPlayerId) {
  // get the tower object and the information of it.
  PartitionOccupyingTower tower = occupyingTowers.removeAt(towerPosition);
  if (tower == null) {
    return CoordinateStream.EMPTY; // return if no tower has been found
  }
  // reduce the tower counter
  changeTowerCounter(tower.playerId, tower.getAreaWithoutGround(), -1);
  // let the other towers occupy the area
  checkOtherTowersInArea(tower);
  PartitionOccupyingTower newTower = new PartitionOccupyingTower(newPlayerId, tower);
  occupyAreaOfTower(newTower);
  return newTower.area.stream();
}
origin: jsettlers/settlers-remake

  /**
   * Removes all construction marks in the given area.
   * 
   * @param area
   *            The area to remove the marks
   * @param notIn
   *            The area of marks that should be skipped.
   */
  private void removeConstructionMarks(IMapArea area, IMapArea notIn) {
    area.stream()
        .filterBounds(map.getWidth(), map.getHeight())
        .filter((x, y) -> !notIn.contains(x, y))
        .forEach((x, y) -> map.setConstructMarking(x, y, false, false, null));
  }
}
origin: jsettlers/settlers-remake

private void selectArea(SelectAreaAction action) {
  final SelectionSet selectionSet = new SelectionSet();
  action.getArea().stream().filterBounds(grid.getWidth(), grid.getHeight()).forEach((x, y) -> {
    final IGuiMovable movable = grid.getMovable(x, y);
    if (movable != null && canSelectPlayer(movable.getPlayer().getPlayerId())) {
      selectionSet.add(movable);
    }
    final IBuilding building = grid.getBuildingAt(x, y);
    if (building != null && canSelectPlayer(building.getPlayer().getPlayerId())) {
      selectionSet.add(building);
    }
  });
  setSelection(selectionSet);
}
origin: jsettlers/settlers-remake

/**
 * Checks if other towers that intersect the area of the given tower can occupy free positions of the area of the given tower and lets them do so.
 * 
 * @param tower
 */
private void checkOtherTowersInArea(PartitionOccupyingTower tower) {
  // Get the positions that may change their owner (tower counter <= 0)
  // Save these positions in the list because the list must not change during the loop over the other towers
  CoordinateStream freedPositions = tower.area.stream().filter((x, y) -> towers[x + y * width] <= 0).freeze();
  // if at least one position may change the player
  // check if other towers occupy the area
  if (!freedPositions.isEmpty()) {
    List<Tuple<Integer, PartitionOccupyingTower>> towersInRange = occupyingTowers.getTowersInRange(tower.position,
        tower.radius, currTower -> currTower.playerId != tower.playerId);
    // sort the towers by their distance to the removed tower
    Lists.sort(towersInRange, Tuple.getE1Comparator());
    for (Tuple<Integer, PartitionOccupyingTower> curr : towersInRange) {
      final PartitionOccupyingTower currTower = curr.e2;
      final IMapArea currArea = currTower.area;
      CoordinateStream area = freedPositions.filter(currArea::contains);
      occupyAreaByTower(currTower.playerId, area, currTower.areaBorders);
      PartitionsListingBorderVisitor borderVisitor = new PartitionsListingBorderVisitor(this, blockingProvider);
      final FreeMapArea groundArea = currTower.groundArea;
      ShortPoint2D upperLeftGroundAreaPosition = groundArea.getUpperLeftPosition();
      BorderTraversingAlgorithm.traverseBorder(groundArea::contains, upperLeftGroundAreaPosition, borderVisitor, true);
      checkMergesAndDividesOnPartitionsList(currTower.playerId,
          getPartitionIdAt(upperLeftGroundAreaPosition.x, upperLeftGroundAreaPosition.y), borderVisitor.getPartitionsList());
    }
  }
}
jsettlers.common.map.shapesIMapAreastream

Popular methods of IMapArea

  • contains
    Checks whether the given position is contained by the shape. It is not guaranteed that they are also
  • iterator
    Gets an iterator for the shape that returns all tiles that are contained by this shape. The iterator

Popular in Java

  • Making http requests using okhttp
  • setScale (BigDecimal)
  • getResourceAsStream (ClassLoader)
  • getContentResolver (Context)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now