summaryrefslogtreecommitdiff
path: root/src/World
diff options
context:
space:
mode:
Diffstat (limited to 'src/World')
-rw-r--r--src/World/BlockType.hpp12
-rw-r--r--src/World/ChunkIndex.hpp8
2 files changed, 19 insertions, 1 deletions
diff --git a/src/World/BlockType.hpp b/src/World/BlockType.hpp
index 2a9a652..cfac43b 100644
--- a/src/World/BlockType.hpp
+++ b/src/World/BlockType.hpp
@@ -26,6 +26,16 @@ public:
operator Value() const { return m_block; }
+ Bool is_solid() const {
+ switch (m_block) {
+ case Air:
+ case Water:
+ return false;
+ default:
+ return true;
+ }
+ }
+
Bool is_translucent() const { return opacity() != 1.0; }
Real opacity() const {
@@ -58,4 +68,4 @@ private:
Value m_block;
};
-} \ No newline at end of file
+}
diff --git a/src/World/ChunkIndex.hpp b/src/World/ChunkIndex.hpp
index bc61f3d..da23e3d 100644
--- a/src/World/ChunkIndex.hpp
+++ b/src/World/ChunkIndex.hpp
@@ -31,6 +31,14 @@ struct ChunkIndex {
return {chunk_x, chunk_y};
}
+ static ChunkIndex from_position(Position::World pos) {
+ return from_position(pos.round_to_block());
+ }
+
+ Bool operator==(const ChunkIndex& other) const {
+ return x == other.x && y == other.y;
+ }
+
I32 x, y;
};