#pragma once #include #include #include #include #include "ISaveable.h" namespace ZL { struct Item { std::string id; std::string name; std::string description; std::string icon; std::string selectedIcon; Item() = default; Item(const std::string& _id, const std::string& _name, const std::string& _desc, const std::string& _icon) : id(_id), name(_name), description(_desc), icon(_icon) { } }; class Inventory : public ISaveable { public: void addItem(const std::string& itemId); void removeItem(const std::string& itemId); // Resolves current items from ItemRegistry by id, so returned data // always reflects the currently loaded (localized) definitions. std::vector getItems() const; bool hasItem(const std::string& itemId) const; void clear() { itemIds.clear(); } size_t getCount() const { return itemIds.size(); } void save(nlohmann::json& out) const override; void load(const nlohmann::json& in) override; // Called whenever an item is added/removed; receives the item id. std::function onItemAdded; std::function onItemRemoved; private: std::vector itemIds; }; } // namespace ZL