#ifndef SHARED_ITEM_ITEM_HH_ #define SHARED_ITEM_ITEM_HH_ #include #include "shared/net/proto.hh" #include "shared/world/block.hh" #include "shared/world/chunk.hh" namespace shared { namespace item { // ABC for items that exist in a player's inventory. (TODO abc lol) class item { public: using type_t = std::uint32_t; public: type_t type; std::uint32_t quantity; public: item(const type_t& type, const std::uint32_t& quantity) noexcept : type(type), quantity(quantity) {} item(const proto::item& item) noexcept : type(item.type()), quantity(item.quantity()) {} virtual ~item() noexcept {} public: static std::uint32_t get_max_stack(const type_t& type) noexcept; public: virtual type_t get_type() const noexcept { return this->type; } public: // protobuf stuff void pack(proto::item* const proto, const std::uint32_t inventory_index) const noexcept { proto->set_type(this->type); proto->set_quantity(this->quantity); proto->set_index(inventory_index); } }; } // namespace item } // namespace shared #endif