diff options
Diffstat (limited to 'src/shared/world/block.hh')
| -rw-r--r-- | src/shared/world/block.hh | 54 |
1 files changed, 54 insertions, 0 deletions
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 <cstdint> + +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 |
