nw::Inventory
-
struct Inventory
Public Types
-
using Storage = std::bitset<total_slots_per_page>
Public Functions
-
explicit Inventory(ObjectBase *owner_, nw::MemoryResource *allocator = nw::kernel::global_allocator())
-
Inventory(int pages, int rows, int columns, nw::MemoryResource *allocator = nw::kernel::global_allocator())
-
Inventory(int pages, int rows, int columns, ObjectBase *owner_, nw::MemoryResource *allocator = nw::kernel::global_allocator())
-
~Inventory() = default
-
void destroy()
-
bool instantiate()
-
bool add_page()
Adds a page to the inventory.
-
bool check_available(int page, int row, int col, int width, int height) const noexcept
Checks if slots for item of width x height is availble at a particular page, row, and column.
-
bool clear_item(int page, int row, int col, int width, int height)
Clears an item from the inventory grid.
-
std::string debug() const
Gets a string representation of the occupied inventory slots.
-
InventorySlot find_slot(int width, int height) const noexcept
Finds first available slot for item of width x height.
-
bool insert_item(int page, int row, int col, int width, int height)
Sets an item from the inventory grid.
-
inline int pages() const noexcept
Gets current number of pages.
-
void set_growable(bool value)
Sets the inventory to allow adding pages dynamically (for stores)
-
size_t size() const noexcept
Gets number of items in the inventory.
-
std::pair<uint16_t, uint16_t> slot_to_xy(InventorySlot slot) const noexcept
Converts coordinates from our page, row, col to bioware x,y cooardinates.
-
InventorySlot xy_to_slot(uint16_t x, uint16_t y) const noexcept
Converts bioware x,y cooardinates to our page, row, col coordinates.
-
bool from_json(const nlohmann::json &archive, SerializationProfile profile)
-
nlohmann::json to_json(SerializationProfile profile) const
Public Members
-
ObjectBase *owner
-
FixedVector<InventoryItem> items
-
int pages_ = default_pages
-
int columns_ = max_columns
-
bool growable_ = false
-
using Storage = std::bitset<total_slots_per_page>