From 73cbcdd6e8c849e32abbf9757e603e6a6654e870 Mon Sep 17 00:00:00 2001 From: untodesu Date: Fri, 12 Sep 2025 14:09:34 +0500 Subject: Metaitems --- game/shared/world/item_registry.hh | 55 +++++--------------------------------- 1 file changed, 6 insertions(+), 49 deletions(-) (limited to 'game/shared/world/item_registry.hh') diff --git a/game/shared/world/item_registry.hh b/game/shared/world/item_registry.hh index 2274da2..b4c9fda 100644 --- a/game/shared/world/item_registry.hh +++ b/game/shared/world/item_registry.hh @@ -1,61 +1,18 @@ #pragma once -#include "core/resource/resource.hh" - -#include "shared/types.hh" - -// This resource is only defined client-side and -// resource_ptr should remain set to null -// anywhere else in the shared and server code -struct TextureGUI; - -namespace world -{ -class Voxel; -} // namespace world - -namespace world -{ -struct ItemInfo final { - std::string name; - std::string texture; - const Voxel* place_voxel; - - resource_ptr cached_texture; // Client-side only -}; -} // namespace world - -namespace world -{ -class ItemInfoBuilder final { -public: - explicit ItemInfoBuilder(std::string_view name); - virtual ~ItemInfoBuilder(void) = default; - -public: - ItemInfoBuilder& set_texture(std::string_view texture); - ItemInfoBuilder& set_place_voxel(const Voxel* place_voxel); - -public: - item_id build(void) const; - -private: - ItemInfo prototype; -}; -} // namespace world +#include "shared/world/item.hh" namespace world::item_registry { -extern std::unordered_map builders; extern std::unordered_map names; -extern std::vector> items; +extern std::vector> items; } // namespace world::item_registry namespace world::item_registry { -ItemInfoBuilder& construct(std::string_view name); -ItemInfo* find(std::string_view name); -ItemInfo* find(const item_id item); +Item* register_item(const ItemBuilder& builder); +Item* find(std::string_view name); +Item* find(const item_id item); } // namespace world::item_registry namespace world::item_registry @@ -65,5 +22,5 @@ void purge(void); namespace world::item_registry { -std::uint64_t calculate_checksum(void); +std::uint64_t get_checksum(void); } // namespace world::item_registry -- cgit