void cPrefabStructure::DrawIntoChunk(cChunkDesc & a_Chunk) { // Iterate over all items // Each intersecting prefab is placed on ground, if requested, then drawn for (cPlacedPieces::iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr) { const cPrefab & Prefab = static_cast<const cPrefab &>((*itr)->GetPiece()); if (Prefab.ShouldMoveToGround() && !(*itr)->HasBeenMovedToGround()) { PlacePieceOnGround(**itr); } Prefab.Draw(a_Chunk, *itr); } // for itr - m_PlacedPieces[] }
cVillage( int a_Seed, int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_MaxRoadDepth, int a_MaxSize, int a_Density, cPiecePool & a_Prefabs, cTerrainHeightGenPtr a_HeightGen, BLOCKTYPE a_RoadBlock, BLOCKTYPE a_WaterRoadBlock ) : super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), m_Seed(a_Seed), m_Noise(a_Seed), m_MaxSize(a_MaxSize), m_Density(a_Density), m_Borders(a_OriginX - a_MaxSize, 0, a_OriginZ - a_MaxSize, a_OriginX + a_MaxSize, cChunkDef::Height - 1, a_OriginZ + a_MaxSize), m_Prefabs(a_Prefabs), m_HeightGen(a_HeightGen), m_RoadBlock(a_RoadBlock), m_WaterRoadBlock(a_WaterRoadBlock) { // Generate the pieces for this village; don't care about the Y coord: cBFSPieceGenerator pg(*this, a_Seed); pg.PlacePieces(a_OriginX, 0, a_OriginZ, a_MaxRoadDepth + 1, m_Pieces); if (m_Pieces.empty()) { return; } // If the central piece should be moved to ground, move it, and // check all of its dependents and move those that are strictly connector-driven based on its new Y coord: if (((cPrefab &)m_Pieces[0]->GetPiece()).ShouldMoveToGround()) { int OrigPosY = m_Pieces[0]->GetCoords().y; PlacePieceOnGround(*m_Pieces[0]); int NewPosY = m_Pieces[0]->GetCoords().y; MoveAllDescendants(m_Pieces, 0, NewPosY - OrigPosY); } }
// cGridStructGen::cStructure overrides: virtual void DrawIntoChunk(cChunkDesc & a_Chunk) override { // Iterate over all items // Each intersecting prefab is placed on ground, then drawn // Each intersecting road is drawn by replacing top soil blocks with gravel / sandstone blocks cChunkDef::HeightMap HeightMap; // Heightmap for this chunk, used by roads m_HeightGen->GenHeightMap(a_Chunk.GetChunkX(), a_Chunk.GetChunkZ(), HeightMap); for (cPlacedPieces::iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr) { cPrefab & Prefab = (cPrefab &)((*itr)->GetPiece()); if ((*itr)->GetPiece().GetSize().y == 1) { // It's a road, special handling (change top terrain blocks to m_RoadBlock) DrawRoad(a_Chunk, **itr, HeightMap); continue; } if (Prefab.ShouldMoveToGround() && !(*itr)->HasBeenMovedToGround()) { PlacePieceOnGround(**itr); } Prefab.Draw(a_Chunk, *itr); } // for itr - m_PlacedPieces[] }