| 489 | |
| 490 | |
| 491 | WorldTemplate::PotentialBiomeItems WorldTemplate::potentialBiomeItemsAt(int x, int y) const { |
| 492 | if (!m_layout || y <= 0 || y >= (int)m_geometry.height() - 1) |
| 493 | return {}; |
| 494 | x = m_geometry.xwrap(x); |
| 495 | |
| 496 | auto blockBiome = [this](int x, int y) -> Biome const* { |
| 497 | BiomeIndex index = blockBiomeIndex(m_geometry.xwrap(x), y); |
| 498 | if (index == NullBiomeIndex) |
| 499 | return nullptr; |
| 500 | return m_layout->getBiome(index).get(); |
| 501 | }; |
| 502 | |
| 503 | auto lowerBlockBiome = blockBiome(x, y - 1); |
| 504 | auto upperBlockBiome = blockBiome(x, y + 1); |
| 505 | auto thisBlockBiome = blockBiome(x, y); |
| 506 | |
| 507 | PotentialBiomeItems potentialBiomeItems; |
| 508 | // surface floor, surface ocean |
| 509 | if (lowerBlockBiome) |
| 510 | addPotentialBiomeItems(x, y, potentialBiomeItems, lowerBlockBiome->surfacePlaceables.itemDistributions, BiomePlacementArea::Surface, BiomePlacementMode::Floor); |
| 511 | if (thisBlockBiome) |
| 512 | addPotentialBiomeItems(x, y, potentialBiomeItems, thisBlockBiome->surfacePlaceables.itemDistributions, BiomePlacementArea::Surface, BiomePlacementMode::Ocean); |
| 513 | |
| 514 | // underground floor, ceiling, background |
| 515 | if (lowerBlockBiome) |
| 516 | addPotentialBiomeItems(x, y, potentialBiomeItems, lowerBlockBiome->undergroundPlaceables.itemDistributions, BiomePlacementArea::Underground, BiomePlacementMode::Floor); |
| 517 | if (upperBlockBiome) |
| 518 | addPotentialBiomeItems(x, y, potentialBiomeItems, upperBlockBiome->undergroundPlaceables.itemDistributions, BiomePlacementArea::Underground, BiomePlacementMode::Ceiling); |
| 519 | if (thisBlockBiome) |
| 520 | addPotentialBiomeItems(x, y, potentialBiomeItems, thisBlockBiome->undergroundPlaceables.itemDistributions, BiomePlacementArea::Underground, BiomePlacementMode::Background); |
| 521 | |
| 522 | return potentialBiomeItems; |
| 523 | } |
| 524 | |
| 525 | List<BiomeItemPlacement> WorldTemplate::validBiomeItems(int x, int y, PotentialBiomeItems potentialBiomeItems) const { |
| 526 | if (y <= 0 || y >= (int)m_geometry.height() - 1) |
no test coverage detected