aboutsummaryrefslogtreecommitdiff
path: root/src/shared/item/item.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/item/item.hh')
-rw-r--r--src/shared/item/item.hh49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/shared/item/item.hh b/src/shared/item/item.hh
new file mode 100644
index 0000000..3774189
--- /dev/null
+++ b/src/shared/item/item.hh
@@ -0,0 +1,49 @@
+#ifndef SHARED_ITEM_ITEM_HH_
+#define SHARED_ITEM_ITEM_HH_
+
+#include <cstdint>
+
+#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