diff options
| author | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2025-02-12 21:57:46 +1100 |
|---|---|---|
| committer | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2025-02-12 21:57:46 +1100 |
| commit | e4483eca01b48b943cd0461e24a74ae1a3139ed4 (patch) | |
| tree | ed58c3c246e3af1af337697695d780aa31f6ad9a /src/shared/world/block.hh | |
| parent | 1cc08c51eb4b0f95c30c0a98ad1fc5ad3459b2df (diff) | |
Update to most recent version (old initial commit)
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 |
