Exemple #1
0
  public int terrToChunkMap(Territory terr, int terrId, boolean relativeTo0x0) {
    int xOffset = relativeTo0x0 ? 0 : terr.getXChunkCoord();
    int yOffset = relativeTo0x0 ? 0 : terr.getYChunkCoord();
    int thisIslandId = IslandList.INVALID_ISLAND_ID;

    if (this.inWorld()) {
      thisIslandId = this.world.getIslandList().addIsland(player, terrId);
    } else {
      thisIslandId = terrId;
    }

    CanonDecoder c =
        new CanonDecoder(
            Types.findByTypeName("puzzlePiece"),
            terr.getCanon(),
            terr.getRot(),
            new BoardCoord(
                this.cRect.getTl().getX() + xOffset, this.cRect.getTl().getY() + yOffset));

    int indexWithinTerr = 0;

    while (c.isValid()) {
      ChunkCoord cc = new ChunkCoord((int) c.getPos().getX(), (int) c.getPos().getY());
      Chunk ch = this.cMap.getChunk(cc);
      ch.setIslandId(thisIslandId);
      ch.setTerr(terr);
      ch.setIndexWithinTerr(indexWithinTerr);
      ch.setSideOrientation(c.getOrientation());

      c.getNext();
      ++indexWithinTerr;
    }

    if (this.inWorld()) {
      this.world
          .getIslandList()
          .setBoardCoordRect(
              thisIslandId, this.cMap.getChunkCoordRect(thisIslandId).getBoardCoordRect());
    }

    return thisIslandId;
  }