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; }
36 const WorldSave &SaveFile() const noexcept { return save; }
38 Chunk *Loaded(const Chunk::Pos &) noexcept;
39 bool Queued(const Chunk::Pos &) noexcept;
40 bool Known(const Chunk::Pos &) noexcept;
41 Chunk &ForceLoad(const Chunk::Pos &);
43 bool OutOfRange(const Chunk &c) const noexcept { return OutOfRange(c.Position()); }
44 bool OutOfRange(const Chunk::Pos &) const noexcept;
46 void Rebase(const Chunk::Pos &);
49 std::size_t ToLoad() const noexcept { return to_load.size(); }
50 // returns true if the chunk was generated
52 void LoadN(std::size_t n);
55 Chunk &Load(const Chunk::Pos &pos);
56 // link given chunk to all loaded neighbors
57 void Insert(Chunk &) noexcept;
58 // remove a loaded chunk
59 // this unlinks it from its neighbors as well as moves it to the free list
60 // given iterator must point to a chunk from the loaded list
61 // returns an iterator to the chunk following the removed one
62 // in the loaded list (end for the last one)
63 std::list<Chunk>::iterator Remove(std::list<Chunk>::iterator) noexcept;
68 const BlockTypeRegistry ®
70 const WorldSave &save;
72 std::list<Chunk> loaded;
73 std::list<Chunk::Pos> to_load;
74 std::list<Chunk> to_free;
76 IntervalTimer gen_timer;