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.cc | 85 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/shared/world/block.cc (limited to 'src/shared/world/block.cc') diff --git a/src/shared/world/block.cc b/src/shared/world/block.cc new file mode 100644 index 0000000..4d66462 --- /dev/null +++ b/src/shared/world/block.cc @@ -0,0 +1,85 @@ +#include "shared/world/block.hh" + +namespace shared { +namespace world { + +enum block::visibility +block::get_visibility(const enum block::type type) noexcept { + switch (type) { + case type::air: + return visibility::invisible; + case type::shrub: + case type::dead_shrub: + case type::leaves: + case type::snowy_leaves: + case type::snowy_shrub: + return visibility::partial; + case type::water: + return visibility::translucent; + default: + break; + } + return visibility::solid; +} + +bool block::is_tangible(const enum block::type type) noexcept { + switch (type) { + case type::air: + case type::shrub: + case type::dead_shrub: + case type::snowy_shrub: + return false; + default: + break; + } + return true; +} + +bool block::is_collidable(const enum block::type type) noexcept { + switch (type) { + case type::air: + case type::shrub: + case type::dead_shrub: + case type::snowy_shrub: + case type::water: + return false; + default: + break; + } + return true; +} + +bool block::is_liquid(const enum block::type type) noexcept { + switch (type) { + case type::water: + return true; + default: + break; + } + return false; +} + +bool block::is_replaceable(const enum block::type type) noexcept { + switch (type) { + case type::water: + case type::air: + return true; + default: + break; + } + return false; +} + +bool block::is_removable(const enum block::type type) noexcept { + switch (type) { + case type::water: + case type::air: + return false; + default: + break; + } + return true; +} + +} // namespace world +} // namespace shared -- cgit v1.2.3