blob: 2aa7cef72cf8a206b5a3bdce54ad61364a55708f (
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
|
#ifndef SHARED_ITEM_BLOCK_HH_
#define SHARED_ITEM_BLOCK_HH_
#include "shared/item/item.hh"
#include "shared/world/block.hh"
namespace shared {
namespace item {
class block : virtual public shared::item::item {
public:
// Blocks are offset by 256 in their type so they do not collide with tools
// I'd prefer it was the other way around so TODO
static constexpr auto type_offset{std::numeric_limits<std::uint8_t>::max()};
public:
enum shared::world::block::type type;
public:
static type_t get_type(const enum shared::world::block::type&) noexcept;
public:
virtual type_t get_type() const noexcept;
public:
template <typename... Args>
block(const enum shared::world::block::type& type, Args&&... args) noexcept
: item(get_type(type), std::forward<Args>(args)...), type(type) {}
template <typename... Args>
block(const shared::item::item::type_t& type, Args&&... args) noexcept
: item(type, std::forward<Args>(args)...),
type(static_cast<enum shared::world::block::type>(type -
type_offset)) {}
virtual ~block() noexcept {}
};
} // namespace item
} // namespace shared
#endif
|