]> git.localhorst.tv Git - blank.git/blobdiff - src/world/BlockLookup.hpp
block type prototypability and new types
[blank.git] / src / world / BlockLookup.hpp
index e861b249efd628b8c4dc83b74ef792e2fab97cd3..214608ef49ce14ca06c1d2de3b69a05133081f67 100644 (file)
@@ -2,6 +2,7 @@
 #define BLANK_WORLD_BLOCKLOOKUP_HPP_
 
 #include "Block.hpp"
+#include "BlockType.hpp"
 #include "Chunk.hpp"
 
 
@@ -11,22 +12,25 @@ class BlockLookup {
 
 public:
        /// resolve chunk/position from oob coordinates
-       BlockLookup(Chunk *c, const Chunk::Pos &p) noexcept;
+       BlockLookup(Chunk *c, const RoughLocation::Fine &p) noexcept;
 
        /// resolve chunk/position from ib coordinates and direction
-       BlockLookup(Chunk *c, const Chunk::Pos &p, Block::Face dir) noexcept;
+       BlockLookup(Chunk *c, const RoughLocation::Fine &p, Block::Face dir) noexcept;
 
        /// check if lookup was successful
        operator bool() const { return chunk; }
 
        // only valid if lookup was successful
        Chunk &GetChunk() const noexcept { return *chunk; }
-       const Chunk::Pos &GetBlockPos() const noexcept { return pos; }
-       Block::Pos GetBlockCoords() const noexcept { return Chunk::ToCoords(pos); }
+       const RoughLocation::Fine &GetBlockPos() const noexcept { return pos; }
+       int GetBlockIndex() const noexcept { return Chunk::ToIndex(pos); }
+       ExactLocation::Fine GetBlockCoords() const noexcept { return Chunk::ToCoords(pos); }
        const Block &GetBlock() const noexcept { return GetChunk().BlockAt(GetBlockPos()); }
        const BlockType &GetType() const noexcept { return GetChunk().Type(GetBlock()); }
        int GetLight() const noexcept { return GetChunk().GetLight(GetBlockPos()); }
 
+       bool FaceFilled(Block::Face f) const noexcept { return GetType().FaceFilled(GetBlock(), f); }
+
        void SetBlock(const Block &b) noexcept { GetChunk().SetBlock(GetBlockPos(), b); }
 
        // traverse in given direction
@@ -34,7 +38,7 @@ public:
 
 private:
        Chunk *chunk;
-       Chunk::Pos pos;
+       RoughLocation::Fine pos;
 
 };