aboutsummaryrefslogtreecommitdiff
path: root/src/shared/world/block.hh
blob: f8d4e110af3f1ce26e7176b7e928009d5cd20127 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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