]> git.localhorst.tv Git - blank.git/blobdiff - src/world/ChunkIndex.hpp
random stuff
[blank.git] / src / world / ChunkIndex.hpp
index 17b9dd697de901f38b4febbb8e6ba4e40241c2d2..91fc704909114a2980f60346364d1a4d7ff97934 100644 (file)
@@ -1,7 +1,9 @@
 #ifndef BLANK_WORLD_CHUNKINDEX_HPP_
 #define BLANK_WORLD_CHUNKINDEX_HPP_
 
+#include "BlockLookup.hpp"
 #include "Chunk.hpp"
+#include "../rand/GaloisLFSR.hpp"
 
 #include <vector>
 
@@ -30,6 +32,13 @@ public:
        Chunk *operator [](int i) noexcept { return chunks[i]; }
        const Chunk *operator [](int i) const noexcept { return chunks[i]; }
 
+       Chunk *RandomChunk(GaloisLFSR &rand) {
+               return rand.From(chunks);
+       }
+       BlockLookup RandomBlock(GaloisLFSR &rand) {
+               return BlockLookup(RandomChunk(rand), Chunk::ToPos(rand.Next<unsigned int>() % Chunk::size));
+       }
+
        int Extent() const noexcept { return extent; }
 
        Chunk::Pos CoordsBegin() const noexcept { return base - Chunk::Pos(extent); }