blob: 41fd1b01dba96b73c942cd0edc9ad6e728770c9b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include "ChunkRegistry.hpp"
namespace MC::World {
ChunkRegistry::Data& ChunkRegistry::get(ChunkIndex index) {
auto entry = m_chunks.find(index);
if (entry == m_chunks.end()) {
Data data{index, Status::Empty};
m_chunks.insert({index, std::move(data)});
return m_chunks.at(index);
}
return entry->second;
}
ChunkRegistry::Data& ChunkRegistry::find(Position::BlockWorld pos) {
return get({
static_cast<I32>(pos.x() / Chunk::Width),
static_cast<I32>(pos.z() / Chunk::Width)
});
}
ChunkRegistry::Data& ChunkRegistry::find(ChunkIndex chunk, Position::BlockLocal pos) {
return find(chunk.world(pos));
}
}
|