From e4483eca01b48b943cd0461e24a74ae1a3139ed4 Mon Sep 17 00:00:00 2001 From: Nicolas James Date: Wed, 12 Feb 2025 21:57:46 +1100 Subject: Update to most recent version (old initial commit) --- src/shared/world/block.hh | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/shared/world/block.hh (limited to 'src/shared/world/block.hh') diff --git a/src/shared/world/block.hh b/src/shared/world/block.hh new file mode 100644 index 0000000..f8d4e11 --- /dev/null +++ b/src/shared/world/block.hh @@ -0,0 +1,54 @@ +#ifndef SHARED_WORLD_BLOCK_BLOCK_HH_ +#define SHARED_WORLD_BLOCK_BLOCK_HH_ + +#include + +namespace shared { +namespace world { + +class block { +public: + enum class type : std::uint8_t { + air, // zero means air which means don't render + dirt, // atlas should start from here + grass, + sand, + sandstone, + stone, + cobblestone, + wood, + leaves, + water, + shrub, + snow, + cactus, + dead_shrub, + snowy_wood, + snowy_leaves, + snowy_shrub, + }; + enum class visibility { solid, partial, translucent, invisible }; + +public: + type type; + +public: + // We prefer a static switch statement over constructing an object for + // speed. + static enum visibility get_visibility(const enum type type) noexcept; + static bool is_tangible(const enum type type) noexcept; + static bool is_collidable(const enum type type) noexcept; + static bool is_liquid(const enum type type) noexcept; + static bool is_replaceable(const enum type type) noexcept; + static bool is_removable(const enum type type) noexcept; + +public: + block(const enum type t = type::air) noexcept : type(t) {} + + operator enum block::type() const noexcept { return this->type; } +}; + +} // namespace world +} // namespace shared + +#endif -- cgit v1.2.3