summaryrefslogtreecommitdiffstats
path: root/src/game/shared/world/item.cc
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-12-11 15:14:26 +0500
committeruntodesu <kirill@untode.su>2025-12-11 15:14:26 +0500
commitf40d09cb8f712e87691af4912f3630d92d692779 (patch)
tree7ac3a4168ff722689372fd489c6f94d0a2546e8f /src/game/shared/world/item.cc
parent8bcbd2729388edc63c82d77d314b583af1447c49 (diff)
downloadvoxelius-f40d09cb8f712e87691af4912f3630d92d692779.tar.bz2
voxelius-f40d09cb8f712e87691af4912f3630d92d692779.zip
Shuffle stuff around
- Use the new and improved hierarchy I figured out when making Prospero chat - Re-add NSIS scripts, again from Prospero - Update most build and utility scripts with their most recent versions
Diffstat (limited to 'src/game/shared/world/item.cc')
-rw-r--r--src/game/shared/world/item.cc55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/game/shared/world/item.cc b/src/game/shared/world/item.cc
new file mode 100644
index 0000000..5e60609
--- /dev/null
+++ b/src/game/shared/world/item.cc
@@ -0,0 +1,55 @@
+#include "shared/pch.hh"
+
+#include "shared/world/item.hh"
+
+#include "core/math/crc64.hh"
+
+#include "shared/world/voxel.hh"
+
+world::Item::Item(const Item& source, item_id id) noexcept : Item(source)
+{
+ m_id = id;
+}
+
+void world::Item::set_cached_texture(resource_ptr<TextureGUI> texture) const noexcept
+{
+ m_cached_texture = std::move(texture);
+}
+
+std::uint64_t world::Item::get_checksum(std::uint64_t combine) const
+{
+ combine = math::crc64(m_name.data(), m_name.size(), combine);
+ combine = math::crc64(m_texture.data(), m_texture.size(), combine);
+
+ std::uint32_t id = m_place_voxel ? m_place_voxel->get_id() : NULL_VOXEL_ID;
+ combine = math::crc64(&id, sizeof(id), combine);
+
+ return combine;
+}
+
+world::ItemBuilder::ItemBuilder(std::string_view name)
+{
+ set_name(name);
+}
+
+void world::ItemBuilder::set_name(std::string_view name)
+{
+ assert(name.size());
+
+ m_name = name;
+}
+
+void world::ItemBuilder::set_texture(std::string_view texture)
+{
+ m_texture = texture;
+}
+
+void world::ItemBuilder::set_place_voxel(const Voxel* place_voxel)
+{
+ m_place_voxel = place_voxel;
+}
+
+std::unique_ptr<world::Item> world::ItemBuilder::build(item_id id) const
+{
+ return std::make_unique<Item>(*this, id);
+}