X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FChunkLoader.hpp;h=98b352fbc6e228c08b25c75e15954f01a5652184;hb=4db5e3765bc93606e340f704ae27ca840eae7045;hp=b1d0c7b9e1e6272059b70f5f2920cb881c848f41;hpb=b7d09e1e35ef90282c97509e0020b20db3c7ea9f;p=blank.git diff --git a/src/world/ChunkLoader.hpp b/src/world/ChunkLoader.hpp index b1d0c7b..98b352f 100644 --- a/src/world/ChunkLoader.hpp +++ b/src/world/ChunkLoader.hpp @@ -2,6 +2,7 @@ #define BLANK_WORLD_CHUNKLOADER_HPP_ #include "Chunk.hpp" +#include "../app/IntervalTimer.hpp" #include @@ -17,6 +18,7 @@ public: struct Config { int load_dist = 6; int unload_dist = 8; + int gen_limit = 16; }; ChunkLoader(const Config &, const BlockTypeRegistry &, const Generator &) noexcept; @@ -31,8 +33,11 @@ public: bool Known(const Chunk::Pos &) noexcept; Chunk &ForceLoad(const Chunk::Pos &); + bool OutOfRange(const Chunk &c) const noexcept { return OutOfRange(c.Position()); } + bool OutOfRange(const Chunk::Pos &) const noexcept; + void Rebase(const Chunk::Pos &); - void Update(); + void Update(int dt); private: Chunk &Generate(const Chunk::Pos &pos); @@ -49,6 +54,8 @@ private: std::list to_generate; std::list to_free; + IntervalTimer gen_timer; + int load_dist; int unload_dist;