X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FBlockLookup.hpp;h=214608ef49ce14ca06c1d2de3b69a05133081f67;hb=b94a7dc7daad9ae9be90a39d723e332dae375325;hp=122b3c76f7e76374eaf50aa264513d54564b43c6;hpb=d2fa8ca97d291508ce3812fb052a8255d3190d00;p=blank.git diff --git a/src/world/BlockLookup.hpp b/src/world/BlockLookup.hpp index 122b3c7..214608e 100644 --- a/src/world/BlockLookup.hpp +++ b/src/world/BlockLookup.hpp @@ -2,6 +2,7 @@ #define BLANK_WORLD_BLOCKLOOKUP_HPP_ #include "Block.hpp" +#include "BlockType.hpp" #include "Chunk.hpp" @@ -11,21 +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; } + 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 @@ -33,7 +38,7 @@ public: private: Chunk *chunk; - Chunk::Pos pos; + RoughLocation::Fine pos; };