1 #ifndef BLANK_WORLD_CHUNKINDEX_HPP_
2 #define BLANK_WORLD_CHUNKINDEX_HPP_
16 ChunkIndex(ChunkStore &, const Chunk::Pos &base, int extent);
19 ChunkIndex(const ChunkIndex &) = delete;
20 ChunkIndex &operator =(const ChunkIndex &) = delete;
23 bool InRange(const Chunk::Pos &) const noexcept;
24 int IndexOf(const Chunk::Pos &) const noexcept;
25 Chunk::Pos PositionOf(int) const noexcept;
26 /// returns nullptr if given position is out of range or the chunk
27 /// is not loaded, so also works as a "has" function
28 Chunk *Get(const Chunk::Pos &) noexcept;
29 const Chunk *Get(const Chunk::Pos &) const noexcept;
30 Chunk *operator [](int i) noexcept { return chunks[i]; }
31 const Chunk *operator [](int i) const noexcept { return chunks[i]; }
33 void Register(Chunk &) noexcept;
35 int TotalChunks() const noexcept { return total_length; }
36 int IndexedChunks() const noexcept { return total_indexed; }
37 int MissingChunks() const noexcept { return total_length - total_indexed; }
39 Chunk::Pos NextMissing() noexcept;
41 const Chunk::Pos &Base() const noexcept { return base; }
42 void Rebase(const Chunk::Pos &);
45 int GetCol(int) const noexcept;
47 void Shift(Block::Face);
49 void Clear() noexcept;
52 void Set(int index, Chunk &) noexcept;
53 void Unset(int index) noexcept;
64 std::vector<Chunk *> chunks;