1 #ifndef BLANK_WORLD_CHUNKLOADER_HPP_
2 #define BLANK_WORLD_CHUNKLOADER_HPP_
5 #include "../app/IntervalTimer.hpp"
12 class BlockTypeRegistry;
27 const BlockTypeRegistry &,
32 void Queue(const Chunk::Pos &from, const Chunk::Pos &to);
33 void QueueSurrounding(const Chunk::Pos &);
35 std::list<Chunk> &Loaded() noexcept { return loaded; }
37 Chunk *Loaded(const Chunk::Pos &) noexcept;
38 bool Queued(const Chunk::Pos &) noexcept;
39 bool Known(const Chunk::Pos &) noexcept;
40 Chunk &ForceLoad(const Chunk::Pos &);
42 bool OutOfRange(const Chunk &c) const noexcept { return OutOfRange(c.Position()); }
43 bool OutOfRange(const Chunk::Pos &) const noexcept;
45 void Rebase(const Chunk::Pos &);
48 std::size_t ToLoad() const noexcept { return to_load.size(); }
50 void LoadN(std::size_t n);
53 Chunk &Load(const Chunk::Pos &pos);
54 // link given chunk to all loaded neighbors
55 void Insert(Chunk &) noexcept;
56 // remove a loaded chunk
57 // this unlinks it from its neighbors as well as moves it to the free list
58 // given iterator must point to a chunk from the loaded list
59 // returns an iterator to the chunk following the removed one
60 // in the loaded list (end for the last one)
61 std::list<Chunk>::iterator Remove(std::list<Chunk>::iterator) noexcept;
66 const BlockTypeRegistry ®
68 const WorldSave &save;
70 std::list<Chunk> loaded;
71 std::list<Chunk::Pos> to_load;
72 std::list<Chunk> to_free;
74 IntervalTimer gen_timer;