Merge branch 'master' into SQC-15_paquets

This commit is contained in:
MarcEricMartel
2023-11-13 16:51:27 -05:00
4 changed files with 89 additions and 3 deletions

View File

@@ -16,6 +16,9 @@ void World::SetSeed(uint64_t seed) {
m_seed = seed;
}
Chunk* World::ChunkAt(float x, float y, float z) const {
int cx = (int)x / CHUNK_SIZE_X;
int cz = (int)z / CHUNK_SIZE_Z;
@@ -31,6 +34,24 @@ Chunk* World::ChunkAt(float x, float y, float z) const {
Chunk* World::ChunkAt(const Vector3f& pos) const { return ChunkAt(pos.x, pos.y, pos.z); }
void World::RemoveChunk(int nbReduit)
{
for (int x = 0; x < WORLD_SIZE_X; ++x)
for (int y = 0; y < WORLD_SIZE_Y; ++y)
{
if (x < nbReduit)
m_chunks.Remove(x,y);
if (y < nbReduit)
m_chunks.Remove(x, y);
if (y > WORLD_SIZE_Y - nbReduit)
m_chunks.Remove(x, y);
if (x > WORLD_SIZE_X - nbReduit)
m_chunks.Remove(x, y);
}
}
BlockType World::BlockAt(float x, float y, float z, BlockType defaultBlockType) const {
Chunk* c = ChunkAt(x, y, z);

View File

@@ -28,6 +28,8 @@ public:
Chunk* ChunkAt(float x, float y, float z) const;
Chunk* ChunkAt(const Vector3f& pos) const;
void RemoveChunk(int nbReduit);
BlockType BlockAt(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const;
BlockType BlockAt(const Vector3f& pos, BlockType defaultBlockType = BTYPE_AIR) const;