1
0

Added PieceStructures generator.

This commit is contained in:
Mattes D
2015-11-11 10:32:42 +01:00
parent 1a9c023d6c
commit b8fbba5eb9
56 changed files with 18104 additions and 12079 deletions

View File

@@ -9,6 +9,7 @@
////////////////////////////////////////////////////////////////////////////////
// cEmptyStructure:
@@ -79,6 +80,54 @@ cGridStructGen::cGridStructGen(
cGridStructGen::cGridStructGen(int a_Seed):
m_BaseSeed(a_Seed),
m_Seed(a_Seed),
m_Noise(a_Seed),
m_GridSizeX(256),
m_GridSizeZ(256),
m_MaxOffsetX(128),
m_MaxOffsetZ(128),
m_MaxStructureSizeX(128),
m_MaxStructureSizeZ(128),
m_MaxCacheSize(256)
{
}
void cGridStructGen::SetGeneratorParams(const AStringMap & a_GeneratorParams)
{
ASSERT(m_Cache.empty()); // No changing the params after chunks are generated
m_GridSizeX = GetStringMapInteger<int>(a_GeneratorParams, "GridSizeX", m_GridSizeX);
m_GridSizeZ = GetStringMapInteger<int>(a_GeneratorParams, "GridSizeZ", m_GridSizeZ);
m_MaxOffsetX = GetStringMapInteger<int>(a_GeneratorParams, "MaxOffsetX", m_MaxOffsetX);
m_MaxOffsetZ = GetStringMapInteger<int>(a_GeneratorParams, "MaxOffsetZ", m_MaxOffsetZ);
m_MaxStructureSizeX = GetStringMapInteger<int>(a_GeneratorParams, "MaxStructureSizeX", m_MaxStructureSizeX);
m_MaxStructureSizeZ = GetStringMapInteger<int>(a_GeneratorParams, "MaxStructureSizeZ", m_MaxStructureSizeZ);
// Silently fix out-of-range parameters:
if (m_MaxOffsetX < 1)
{
m_MaxOffsetX = 1;
}
if (m_MaxOffsetZ < 1)
{
m_MaxOffsetZ = 1;
}
// Set the seed based on the seed offset from the parameters:
auto seedOffset = GetStringMapInteger<int>(a_GeneratorParams, "SeedOffset", 0);
m_Seed = m_BaseSeed + seedOffset;
m_Noise.SetSeed(m_Seed);
}
void cGridStructGen::GetStructuresForChunk(int a_ChunkX, int a_ChunkZ, cStructurePtrs & a_Structures)
{
// Calculate the min and max grid coords of the structures to be returned: