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 int Extent() const noexcept { return extent; }
35 Chunk::Pos CoordsBegin() const noexcept { return base - Chunk::Pos(extent); }
36 Chunk::Pos CoordsEnd() const noexcept { return base + Chunk::Pos(extent + 1); }
38 void Register(Chunk &) noexcept;
40 int TotalChunks() const noexcept { return total_length; }
41 int IndexedChunks() const noexcept { return total_indexed; }
42 int MissingChunks() const noexcept { return total_length - total_indexed; }
44 Chunk::Pos NextMissing() noexcept;
46 const Chunk::Pos &Base() const noexcept { return base; }
47 void Rebase(const Chunk::Pos &);
50 int GetCol(int) const noexcept;
52 void Shift(Block::Face);
54 void Clear() noexcept;
57 void Set(int index, Chunk &) noexcept;
58 void Unset(int index) noexcept;
69 std::vector<Chunk *> chunks;