X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FChunkLoader.hpp;h=1c0b98f792b349e69a9f7e997228038cdffcba5a;hb=e4a1425dccd0ba9b106e415dd02809f4308a85ee;hp=b1d0c7b9e1e6272059b70f5f2920cb881c848f41;hpb=b7d09e1e35ef90282c97509e0020b20db3c7ea9f;p=blank.git diff --git a/src/world/ChunkLoader.hpp b/src/world/ChunkLoader.hpp index b1d0c7b..1c0b98f 100644 --- a/src/world/ChunkLoader.hpp +++ b/src/world/ChunkLoader.hpp @@ -1,56 +1,39 @@ #ifndef BLANK_WORLD_CHUNKLOADER_HPP_ #define BLANK_WORLD_CHUNKLOADER_HPP_ -#include "Chunk.hpp" - -#include +#include namespace blank { -class BlockTypeRegistry; +class ChunkStore; class Generator; +class WorldSave; class ChunkLoader { public: - struct Config { - int load_dist = 6; - int unload_dist = 8; - }; - - ChunkLoader(const Config &, const BlockTypeRegistry &, const Generator &) noexcept; + ChunkLoader( + ChunkStore &, + const Generator &, + const WorldSave & + ) noexcept; - void Generate(const Chunk::Pos &from, const Chunk::Pos &to); - void GenerateSurrounding(const Chunk::Pos &); + const WorldSave &SaveFile() const noexcept { return save; } - std::list &Loaded() noexcept { return loaded; } + void Update(int dt); - Chunk *Loaded(const Chunk::Pos &) noexcept; - bool Queued(const Chunk::Pos &) noexcept; - bool Known(const Chunk::Pos &) noexcept; - Chunk &ForceLoad(const Chunk::Pos &); + int ToLoad() const noexcept; - void Rebase(const Chunk::Pos &); - void Update(); - -private: - Chunk &Generate(const Chunk::Pos &pos); - void Insert(Chunk &) noexcept; - void Remove(Chunk &) noexcept; + // returns true if the chunk was generated + // (as opposed to loaded from file) + bool LoadOne(); + void LoadN(std::size_t n); private: - Chunk::Pos base; - - const BlockTypeRegistry ® + ChunkStore &store; const Generator &gen; - - std::list loaded; - std::list to_generate; - std::list to_free; - - int load_dist; - int unload_dist; + const WorldSave &save; };