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(); }
49 // returns true if the chunk was generated
51 void LoadN(std::size_t n);
54 Chunk &Load(const Chunk::Pos &pos);
55 // link given chunk to all loaded neighbors
56 void Insert(Chunk &) noexcept;
57 // remove a loaded chunk
58 // this unlinks it from its neighbors as well as moves it to the free list
59 // given iterator must point to a chunk from the loaded list
60 // returns an iterator to the chunk following the removed one
61 // in the loaded list (end for the last one)
62 std::list<Chunk>::iterator Remove(std::list<Chunk>::iterator) noexcept;
67 const BlockTypeRegistry ®
69 const WorldSave &save;
71 std::list<Chunk> loaded;
72 std::list<Chunk::Pos> to_load;
73 std::list<Chunk> to_free;
75 IntervalTimer gen_timer;