From befe132861b1995dfe776d4e134a90fc243d1a17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Imrich?= Date: Thu, 8 Apr 2021 12:24:59 +0200 Subject: cPieceModifier interface and cPieceModifierRandomizeBlocks class (#5122) --- src/Generating/Prefab.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/Generating/Prefab.cpp') diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index 7c8c3c0bc..0a7b2a89b 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -157,8 +157,24 @@ void cPrefab::Draw(cChunkDesc & a_Dest, const Vector3i & a_Placement, int a_NumR return; } - // Write the image: - a_Dest.WriteBlockArea(Image, Placement.x, Placement.y, Placement.z, m_MergeStrategy); + if (m_Modifiers.size() == 0) + { + // Write the image: + a_Dest.WriteBlockArea(Image, Placement.x, Placement.y, Placement.z, m_MergeStrategy); + } + else + { + cBlockArea RandomizedImage; + Image.CopyTo(RandomizedImage); + + for (size_t i = 0; i < m_Modifiers.size(); i++) + { + m_Modifiers[i]->Modify(RandomizedImage, a_Placement, a_NumRotations); + } + + // Write the modified image: + a_Dest.WriteBlockArea(RandomizedImage, Placement.x, Placement.y, Placement.z, m_MergeStrategy); + } // If requested, draw the floor (from the bottom of the prefab down to the nearest non-air) switch (m_ExtendFloorStrategy) -- cgit v1.2.3