From 3660ce68343ad2e867e49d1650f61fc0eb85ac23 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 15 May 2014 00:12:01 +0200 Subject: cPrefab can be constructed in code. --- src/Generating/Prefab.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/Generating/Prefab.cpp') diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index 0f20603be..9aef7a94b 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -136,6 +136,33 @@ cPrefab::cPrefab(const cPrefab::sDef & a_Def) : ParseConnectors(a_Def.m_Connectors); ParseDepthWeight(a_Def.m_DepthWeight); + AddRotatedBlockAreas(); +} + + + + + +cPrefab::cPrefab(const cBlockArea & a_Image, int a_AllowedRotations) : + m_Size(a_Image.GetSize()), + m_AllowedRotations(a_AllowedRotations), + m_MergeStrategy(cBlockArea::msOverwrite), + m_ShouldExtendFloor(false), + m_DefaultWeight(1), + m_AddWeightIfSame(0) +{ + m_HitBox.p1.Set(0, 0, 0); + m_HitBox.p2.Set(m_Size.x - 1, m_Size.y - 1, m_Size.z - 1); + m_BlockArea[0].CopyFrom(a_Image); + AddRotatedBlockAreas(); +} + + + + + +void cPrefab::AddRotatedBlockAreas(void) +{ // 1 CCW rotation: if ((m_AllowedRotations & 0x01) != 0) { @@ -257,6 +284,15 @@ int cPrefab::GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cC +void cPrefab::AddConnector(int a_RelX, int a_RelY, int a_RelZ, eBlockFace a_Direction, int a_Type) +{ + m_Connectors.push_back(cConnector(a_RelX, a_RelY, a_RelZ, a_Type, a_Direction)); +} + + + + + void cPrefab::ParseCharMap(CharMap & a_CharMapOut, const char * a_CharMapDef) { ASSERT(a_CharMapDef != NULL); -- cgit v1.2.3 From 7004043c6164c6b22346f94489cb823f9495738f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 17 May 2014 21:54:04 +0200 Subject: Village houses are height-adjusted onto the terrain. --- src/Generating/Prefab.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/Generating/Prefab.cpp') diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index 9aef7a94b..506e1c2cc 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -191,13 +191,21 @@ void cPrefab::AddRotatedBlockAreas(void) void cPrefab::Draw(cChunkDesc & a_Dest, const cPlacedPiece * a_Placement) const +{ + Draw(a_Dest, a_Placement->GetCoords(), a_Placement->GetNumCCWRotations()); +} + + + + +void cPrefab::Draw(cChunkDesc & a_Dest, const Vector3i & a_Placement, int a_NumRotations) const { // Draw the basic image: - Vector3i Placement = a_Placement->GetCoords(); + Vector3i Placement(a_Placement); int ChunkStartX = a_Dest.GetChunkX() * cChunkDef::Width; int ChunkStartZ = a_Dest.GetChunkZ() * cChunkDef::Width; Placement.Move(-ChunkStartX, 0, -ChunkStartZ); - const cBlockArea & Image = m_BlockArea[a_Placement->GetNumCCWRotations()]; + const cBlockArea & Image = m_BlockArea[a_NumRotations]; a_Dest.WriteBlockArea(Image, 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) -- cgit v1.2.3 From 96a22cd82c350b1205985a9b8e01f5e6c11f069a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 24 May 2014 15:03:39 +0200 Subject: Added Japanese village prefabs. --- src/Generating/Prefab.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/Generating/Prefab.cpp') diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index 506e1c2cc..05979507a 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -292,6 +292,15 @@ int cPrefab::GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cC +void cPrefab::SetDefaultWeight(int a_DefaultWeight) +{ + m_DefaultWeight = a_DefaultWeight; +} + + + + + void cPrefab::AddConnector(int a_RelX, int a_RelY, int a_RelZ, eBlockFace a_Direction, int a_Type) { m_Connectors.push_back(cConnector(a_RelX, a_RelY, a_RelZ, a_Type, a_Direction)); -- cgit v1.2.3 From 1a742a2b52d32bd22cd57b4d462bee312717e010 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 25 May 2014 23:50:16 +0200 Subject: Added support for Miners' Village. The village contains both prefabs that snap to ground and prefabs that connect strictly via connectors. Fixes #1027. --- src/Generating/Prefab.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/Generating/Prefab.cpp') diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index 05979507a..e41907325 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -127,7 +127,8 @@ cPrefab::cPrefab(const cPrefab::sDef & a_Def) : m_MergeStrategy(a_Def.m_MergeStrategy), m_ShouldExtendFloor(a_Def.m_ShouldExtendFloor), m_DefaultWeight(a_Def.m_DefaultWeight), - m_AddWeightIfSame(a_Def.m_AddWeightIfSame) + m_AddWeightIfSame(a_Def.m_AddWeightIfSame), + m_MoveToGround(a_Def.m_MoveToGround) { m_BlockArea[0].Create(m_Size); CharMap cm; @@ -149,7 +150,8 @@ cPrefab::cPrefab(const cBlockArea & a_Image, int a_AllowedRotations) : m_MergeStrategy(cBlockArea::msOverwrite), m_ShouldExtendFloor(false), m_DefaultWeight(1), - m_AddWeightIfSame(0) + m_AddWeightIfSame(0), + m_MoveToGround(false) { m_HitBox.p1.Set(0, 0, 0); m_HitBox.p2.Set(m_Size.x - 1, m_Size.y - 1, m_Size.z - 1); -- cgit v1.2.3 From 24137e282bc97497bcf8c50745d2d45da59b1a27 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 26 May 2014 10:05:51 +0200 Subject: Fixed prefab test initialization. --- src/Generating/Prefab.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/Generating/Prefab.cpp') diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index e41907325..2ab1455b9 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -108,6 +108,9 @@ static const cPrefab::sDef g_TestPrefabDef = // AddWeightIfSame: 1000, + + // MoveToGround: + false, }; static cPrefab g_TestPrefab(g_TestPrefabDef); -- cgit v1.2.3