Merge branch 'master' into Améloration_Gen_Monde

This commit is contained in:
Louis-CharlesG
2023-12-04 15:44:22 -05:00
172 changed files with 2663 additions and 1037 deletions

View File

@@ -4,7 +4,7 @@
Chunk::Chunk(unsigned int x, unsigned int y, int64_t seed) : m_posX(x), m_posY(y) {
//std::ostringstream pos; // V<>rifie l'existence d'un fichier .chunk avec sa position.
//std::ostringstream pos; // V<>rifie l'existence d'un fichier .chunk avec sa position.
//pos << CHUNK_PATH << x << '_' << y << ".chunk";
//std::ifstream input(pos.str(), std::fstream::binary);
@@ -77,6 +77,38 @@ Chunk::Chunk(unsigned int x, unsigned int y, int64_t seed) : m_posX(x), m_posY(y
}
#pragma endregion
//int rnd = rand() % 15;
if (ratio == 1)
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // structure
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
for (int iy = 0; iy < 14; ++iy) {
if (ix == 3)
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
Structure(ix, iy, iz, 2);
}
}
if (ratio == 3)
for (int ix = 0; ix < CHUNK_SIZE_Z; ++ix) // structure
for (int iz = 0; iz < CHUNK_SIZE_X; ++iz) {
for (int iy = 0; iy < 14; ++iy) {
if (iz == 4)
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
Structure(ix, iy, iz, 1);
}
}
if (ratio == 5)
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // structure
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
for (int iy = 0; iy < 14; ++iy) {
if (ix == 3)
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
Structure(ix, iy, iz, 2);
}
}
#pragma region Arbre
@@ -109,7 +141,7 @@ Chunk::Chunk(unsigned int x, unsigned int y, int64_t seed) : m_posX(x), m_posY(y
int distanceThreshold = 20;
// V<>rifie si l'emplacement n'est pas <20> l'int<6E>rieur des lacs
// V<>rifie si l'emplacement n'est pas <20> l'int<6E>rieur des lacs
bool isInsideLake = false;
for (int iy = 0; iy < 13; ++iy) {
if (GetBlock(ix, iy, iz) == BTYPE_ICE) {
@@ -146,6 +178,9 @@ Chunk::Chunk(unsigned int x, unsigned int y, int64_t seed) : m_posX(x), m_posY(y
//else {
// input.seekg(0, std::ios_base::end);
// int size = input.tellg();
@@ -231,7 +266,7 @@ void Chunk::RemoveBlock(int x, int y, int z, World* world) {
void Chunk::SetBlock(int x, int y, int z, BlockType type, World* world) {
m_blocks.Set(x, y, z, type);
if (world) CheckNeighbors(x, z, world); // Si nullptr, ne pas v<>rifier les chunks voisines.
if (world) CheckNeighbors(x, z, world); // Si nullptr, ne pas v<>rifier les chunks voisines.
m_isDirty = true;
}
@@ -271,3 +306,31 @@ void Chunk::MakeClean() { m_isDirty = false; }
void Chunk::MakeModified() { m_isModified = true; }
void Chunk::Structure(int x, int y, int z,int height)
{
for (int i = 0; i < height; i++)
{
SetBlock(x, i + y, z, BTYPE_GRASS, nullptr);
}
}