Modifications dans Player
This commit is contained in:
		| @@ -11,7 +11,9 @@ Chunk* World::ChunkAt(float x, float y, float z) const { | ||||
|     int cz = (int)z / CHUNK_SIZE_Z; | ||||
|  | ||||
|     if (x < 0 || y < 0 || z < 0 || | ||||
|         x >= WORLD_SIZE_X * CHUNK_SIZE_X || z >= CHUNK_SIZE_Z * WORLD_SIZE_Y || y > CHUNK_SIZE_Y) | ||||
|         x >= WORLD_SIZE_X * CHUNK_SIZE_X ||  | ||||
|         z >= CHUNK_SIZE_Z * WORLD_SIZE_Y ||  | ||||
|         y > CHUNK_SIZE_Y) | ||||
|         return 0; | ||||
|  | ||||
|     return m_chunks.Get(cx, cz); | ||||
| @@ -36,3 +38,44 @@ BlockType World::BlockAt(const Vector3f& pos, BlockType defaultBlockType) const | ||||
|     return BlockAt(pos.x, pos.y, pos.z, defaultBlockType); | ||||
| } | ||||
|  | ||||
| void World::TransposeWorld(Player& player) { | ||||
|     int x = 0; | ||||
|     int y = 0; | ||||
|  | ||||
|     if (player.GetPosition().x > (WORLD_SIZE_X * CHUNK_SIZE_X) * .66f) ++x; | ||||
|     else if (player.GetPosition().x < (WORLD_SIZE_X * CHUNK_SIZE_X) * .33f) --x; | ||||
|     if (player.GetPosition().z > (WORLD_SIZE_Y * CHUNK_SIZE_Z) * .66f) ++y; | ||||
|     else if (player.GetPosition().z < (WORLD_SIZE_Y * CHUNK_SIZE_Z) * .33f) --y; | ||||
|  | ||||
|     if (!x && !y) return; | ||||
|  | ||||
|     if (x != 0)  | ||||
|         for (int ay = 0; ay < WORLD_SIZE_Y; ++ay)  | ||||
|             for (int ax = 0; ax < abs(x); ++ay) | ||||
|                 if (ChunkAt(x < 0 ? (WORLD_SIZE_X - 1 - ax) * WORLD_SIZE_X : ax, 1, ay * WORLD_SIZE_Y)) | ||||
|                     m_tbDeleted.push_back(std::move(m_chunks.Get(x < 0? WORLD_SIZE_X - 1 - ax: ax, ay))); | ||||
|     if (y != 0)  | ||||
|         for (int ax = 0; ax < WORLD_SIZE_X; ++ax) | ||||
|             for (int ay = 0; ay < abs(y); ++ay) | ||||
|                 if (ChunkAt(ax * WORLD_SIZE_X , 1, y < 0 ? (WORLD_SIZE_Y - 1 - ay) * WORLD_SIZE_Y : ay)) | ||||
|                     m_tbDeleted.push_back(std::move(m_chunks.Get(ax, y < 0 ? WORLD_SIZE_Y - 1 - ay: ay))); | ||||
|      | ||||
|     for (int ax = 0; ax < WORLD_SIZE_X; ++ax) | ||||
|         for (int ay = 0; ay < WORLD_SIZE_Y; ++ay)  | ||||
|             if (ax + x < WORLD_SIZE_X && ax + x > 0 && | ||||
|                 ay + y < WORLD_SIZE_Y && ay + y > 0) | ||||
|                 m_chunks.Set(x > 0? ax: ax + x, y > 0? ay: ay + y,  | ||||
|                     m_chunks.Get(x < 0 ? ax : ax + x, y < 0 ? ay : ay + y)); | ||||
|     if (x != 0)  | ||||
|         for (int ay = 0; ay < WORLD_SIZE_Y; ++ay) | ||||
|             for (int ax = 0; ax < abs(x); ++ay) | ||||
|                 m_chunks.Set(x > 0 ? WORLD_SIZE_X - 1 - ax : ax, ay, nullptr); | ||||
|     if (y != 0)  | ||||
|         for (int ax = 0; ax < WORLD_SIZE_X; ++ax) | ||||
|             for (int ay = 0; ay < abs(y); ++ay) | ||||
|                 m_chunks.Set(ax, y > 0 ? WORLD_SIZE_Y - 1 - ay : ay, nullptr); | ||||
|      | ||||
|     m_center[0] += x; m_center[1] += y; | ||||
|     player.Transpose(x, y); | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user