EVENGINE_API_FOUNDATION public API. 更多...
#include <InventorySystem.h>
Public 类型 | |
| using | AcceptFn = std::function< bool(const Bag &bag, const ItemDefinition &def, int quantity, std::string *reason)> |
| using | CapacityFn = std::function< bool(const Bag &bag, const ItemDefinition &def, int quantity, std::string *reason)> |
| using | StackFn = std::function< bool(const ItemStack &a, const ItemStack &b, const ItemDefinition &def)> |
| using | ChangeHook = std::function< void(const InventoryChangeEvent &ev)> |
静态 Public 成员函数 | |
| static void | registerAcceptRule (const std::string &name, AcceptFn fn) |
| Registers accept rule. | |
| static void | unregisterAcceptRule (const std::string &name) |
| Unregisters accept rule. | |
| static bool | hasAcceptRule (const std::string &name) |
| True when accept rule. | |
| static void | registerCapacityPolicy (const std::string &name, CapacityFn fn) |
| Registers capacity policy. | |
| static void | unregisterCapacityPolicy (const std::string &name) |
| Unregisters capacity policy. | |
| static bool | hasCapacityPolicy (const std::string &name) |
| True when capacity policy. | |
| static void | registerStackRule (const std::string &name, StackFn fn) |
| Registers stack rule. | |
| static void | unregisterStackRule (const std::string &name) |
| Unregisters stack rule. | |
| static bool | hasStackRule (const std::string &name) |
| True when stack rule. | |
| static void | registerChangeHook (const std::string &name, ChangeHook fn) |
| Registers change hook. | |
| static void | unregisterChangeHook (const std::string &name) |
| Unregisters change hook. | |
| static bool | hasChangeHook (const std::string &name) |
| True when change hook. | |
| static void | ensureBuiltins () |
| 确保内置规则已注册(模块首次使用时自动调用)。 | |
| static bool | canAdd (Bag *bag, const std::string &itemId, int quantity, std::string *reason=nullptr) |
| Can add. | |
| static int | addItem (Bag *bag, const std::string &itemId, int quantity) |
| 返回实际放入数量(可能部分成功)。 | |
| static eve::Result< PreparedInventoryAdd > | prepareAddBatch (Bag *bag, const std::vector< InventoryItemGrant > &grants) |
| Validate a multi-item addition against a private candidate Bag. | |
| static eve::Result< int > | commitAddBatch (PreparedInventoryAdd prepared) |
| Commit one prepared addition and then publish its change events. | |
| static eve::Result< PreparedInventoryRemove > | prepareRemove (Bag *bag, const std::string &itemId, int quantity) |
| Prepare removal of one exact item quantity without mutation or events. | |
| static eve::Result< int > | commitRemove (PreparedInventoryRemove prepared) |
| Commit a prepared removal and publish its event after the no-fail slot swap. | |
| static int | removeItem (Bag *bag, const std::string &itemId, int quantity) |
| static int | removeAt (Bag *bag, int slot, int quantity) |
| Removes at. | |
| static bool | swapSlots (Bag *bag, int slotA, int slotB) |
| Swap slots. | |
| static bool | moveSlot (Bag *bag, int fromSlot, int toSlot) |
| Moves slot. | |
| static bool | splitStack (Bag *bag, int slot, int quantity, int toSlot) |
| Split stack. | |
| static int | transfer (Bag *from, Bag *to, const std::string &itemId, int quantity) |
| Transfer. | |
| static int | transferSlot (Bag *from, int fromSlot, Bag *to, int quantity) |
| Transfer slot. | |
| static int | countItem (const Bag *bag, const std::string &itemId) |
| Returns the number of item. | |
| static int | findItem (const Bag *bag, const std::string &itemId) |
| Finds item. | |
| static int | findItemByTag (const Bag *bag, const std::string &tag) |
| Finds item by tag. | |
| static float | usedWeight (const Bag *bag) |
| Used weight. | |
| static float | usedVolume (const Bag *bag) |
| Used volume. | |
| static int | usedSlotCount (const Bag *bag) |
| Used slot count. | |
| static void | clearBag (Bag *bag) |
| Clears bag. | |
| static bool | equipFromBag (EquipmentSet *eq, const std::string &equipSlot, Bag *bag, int bagSlot) |
| Equip from bag. | |
| static bool | unequipToBag (EquipmentSet *eq, const std::string &equipSlot, Bag *bag) |
| Unequip to bag. | |
| static void | pushEvent (InventoryChangeEvent ev) |
| Pushes event. | |
| static void | pollEvents (std::vector< InventoryChangeEvent > &out) |
| Polls events. | |
| static void | clearEvents () |
| Clears events. | |
| static const std::vector< InventoryChangeEvent > & | events () |
| Events. | |
| static int | nextInstanceId () |
| Next instance id. | |
友元 | |
| class | InventoryResourceAccount |
| class | InventorySaveSession |
详细描述
EVENGINE_API_FOUNDATION public API.
在文件 InventorySystem.h 第 80 行定义.
成员类型定义说明
◆ AcceptFn
| using eve::inventory::InventorySystem::AcceptFn = std::function<bool(const Bag &bag, const ItemDefinition &def, int quantity, std::string *reason)> |
在文件 InventorySystem.h 第 82 行定义.
◆ CapacityFn
| using eve::inventory::InventorySystem::CapacityFn = std::function<bool(const Bag &bag, const ItemDefinition &def, int quantity, std::string *reason)> |
在文件 InventorySystem.h 第 85 行定义.
◆ ChangeHook
| using eve::inventory::InventorySystem::ChangeHook = std::function<void(const InventoryChangeEvent &ev)> |
在文件 InventorySystem.h 第 91 行定义.
◆ StackFn
| using eve::inventory::InventorySystem::StackFn = std::function<bool(const ItemStack &a, const ItemStack &b, const ItemDefinition &def)> |
在文件 InventorySystem.h 第 88 行定义.
成员函数说明
◆ addItem()
|
static |
返回实际放入数量(可能部分成功)。
在文件 InventorySystem.cpp 第 366 行定义.
引用了 itemId.
被这些函数引用 eve::inventory::Bag::addItem(), transfer(), transferSlot() , 以及 unequipToBag().
◆ canAdd()
|
static |
◆ clearBag()
|
static |
◆ clearEvents()
|
static |
Clears events.
在文件 InventorySystem.cpp 第 292 行定义.
◆ commitAddBatch()
|
static |
Commit one prepared addition and then publish its change events.
- 参数
-
prepared Prepared state returned by prepareAddBatch().
- 返回
- Exact added quantity, or Conflict if the Bag changed before commit.
- 备注
- The slot swap is the no-fail commit boundary. Hooks observe only the final Bag state; hook exceptions are isolated from authoritative state. @thread Call on the same simulation thread used for preparation.
在文件 InventorySystem.cpp 第 478 行定义.
引用了 eve::Applied, eve::Conflict, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, eve::Status::success(), eve::Result< T >::success() , 以及 target.
被这些函数引用 eve::rpg::ShopTransaction::buy(), eve::rpg::QuestReward::claim() , 以及 eve::rpg::WorldInteraction::collectLoot().
◆ commitRemove()
|
static |
Commit a prepared removal and publish its event after the no-fail slot swap.
- 返回
- Exact removed quantity, or Conflict when the Bag changed after preparation. @thread Call on the same simulation thread used for preparation.
在文件 InventorySystem.cpp 第 535 行定义.
引用了 eve::Applied, eve::Conflict, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, removed, eve::Status::success(), eve::Result< T >::success() , 以及 target.
被这些函数引用 eve::rpg::ShopTransaction::sell().
◆ countItem()
|
static |
Returns the number of item.
在文件 InventorySystem.cpp 第 814 行定义.
引用了 itemId, n, s , 以及 eve::inventory::Bag::slots().
被这些函数引用 eve::inventory::Bag::countItem(), prepareRemove() , 以及 transfer().
◆ ensureBuiltins()
|
static |
确保内置规则已注册(模块首次使用时自动调用)。
在文件 InventorySystem.cpp 第 142 行定义.
引用了 a, eve::inventory::Bag::acceptTags(), b, eve::inventory::Bag::getMaxVolume(), eve::inventory::Bag::getMaxWeight(), eve::inventory::Bag::getSlotCount(), registerAcceptRule(), registerCapacityPolicy(), registerStackRule(), eve::inventory::Bag::rejectTags(), eve::inventory::ItemDefinition::tags, usedVolume(), usedWeight(), eve::inventory::ItemDefinition::volume , 以及 eve::inventory::ItemDefinition::weight.
被这些函数引用 hasAcceptRule(), hasCapacityPolicy(), hasStackRule(), eve::inventory::Inventory::newBag(), eve::inventory::Inventory::newEquipmentSet(), eve::inventory::InventorySaveSession::prepareRestoreSnapshotJson() , 以及 eve::inventory::Inventory::registerItemsFromJson().
◆ equipFromBag()
|
static |
Equip from bag.
在文件 InventorySystem.cpp 第 885 行定义.
引用了 eve::inventory::InventoryChangeEvent::action, eve::inventory::InventoryChangeEvent::bagId, eve::inventory::EquipmentSet::canEquipFromBag(), eve::inventory::ItemStack::clear(), eve::inventory::InventoryChangeEvent::equipSlot, eve::inventory::Bag::getId(), eve::inventory::InventoryChangeEvent::itemId, eve::inventory::InventoryChangeEvent::quantity, eve::inventory::InventoryChangeEvent::slot, eve::inventory::Bag::slots() , 以及 eve::inventory::EquipmentSet::stackAt().
◆ events()
|
static |
Events.
在文件 InventorySystem.cpp 第 294 行定义.
被这些函数引用 eve::inventory::Inventory::getChangeEventAction(), eve::inventory::Inventory::getChangeEventBagId(), eve::inventory::Inventory::getChangeEventCount(), eve::inventory::Inventory::getChangeEventEquipSlot(), eve::inventory::Inventory::getChangeEventItemId(), eve::inventory::Inventory::getChangeEventOtherBagId(), eve::inventory::Inventory::getChangeEventOtherSlot(), eve::inventory::Inventory::getChangeEventQuantity() , 以及 eve::inventory::Inventory::getChangeEventSlot().
◆ findItem()
|
static |
Finds item.
在文件 InventorySystem.cpp 第 823 行定义.
引用了 eve::inventory::Bag::getSlotCount(), itemId, s , 以及 eve::inventory::Bag::slots().
被这些函数引用 eve::inventory::Bag::findItem().
◆ findItemByTag()
|
static |
Finds item by tag.
在文件 InventorySystem.cpp 第 832 行定义.
引用了 eve::inventory::ItemRegistry::find(), eve::inventory::Bag::getSlotCount(), eve::inventory::ItemDefinition::hasTag(), s, eve::inventory::Bag::slots() , 以及 tag.
被这些函数引用 eve::inventory::Bag::findItemByTag().
◆ hasAcceptRule()
|
static |
True when accept rule.
在文件 InventorySystem.cpp 第 100 行定义.
引用了 ensureBuiltins() , 以及 name.
被这些函数引用 eve::inventory::Inventory::hasAcceptRule() , 以及 eve::inventory::InventorySaveSession::prepareRestoreSnapshotJson().
◆ hasCapacityPolicy()
|
static |
True when capacity policy.
在文件 InventorySystem.cpp 第 114 行定义.
引用了 ensureBuiltins() , 以及 name.
被这些函数引用 eve::inventory::Inventory::hasCapacityPolicy() , 以及 eve::inventory::InventorySaveSession::prepareRestoreSnapshotJson().
◆ hasChangeHook()
|
static |
◆ hasStackRule()
|
static |
True when stack rule.
在文件 InventorySystem.cpp 第 126 行定义.
引用了 ensureBuiltins() , 以及 name.
被这些函数引用 eve::inventory::Inventory::hasStackRule() , 以及 eve::inventory::InventorySaveSession::prepareRestoreSnapshotJson().
◆ moveSlot()
|
static |
Moves slot.
在文件 InventorySystem.cpp 第 607 行定义.
引用了 eve::inventory::InventoryChangeEvent::action, eve::inventory::InventoryChangeEvent::bagId, eve::inventory::ItemRegistry::find(), from, eve::inventory::Bag::getId(), eve::inventory::Bag::getSlotCount(), eve::inventory::InventoryChangeEvent::itemId, eve::inventory::ItemDefinition::maxStack, eve::inventory::InventoryChangeEvent::otherSlot, eve::inventory::InventoryChangeEvent::quantity, eve::inventory::InventoryChangeEvent::slot, eve::inventory::Bag::slots(), swapSlots() , 以及 to.
被这些函数引用 eve::inventory::Bag::moveSlot().
◆ nextInstanceId()
|
static |
Next instance id.
在文件 InventorySystem.cpp 第 229 行定义.
被这些函数引用 splitStack(), transferSlot() , 以及 unequipToBag().
◆ pollEvents()
|
static |
Polls events.
在文件 InventorySystem.cpp 第 287 行定义.
◆ prepareAddBatch()
|
static |
Validate a multi-item addition against a private candidate Bag.
- 参数
-
bag Borrowed Bag that must remain alive and unmodified until commit. grants Exact positive quantities; duplicate item ids are allowed.
- 返回
- A move-only prepared mutation, or a structured failure without mutation/events. @thread Call on the Bag owning simulation thread. @reentrancy No change hooks are invoked during preparation.
在文件 InventorySystem.cpp 第 434 行定义.
引用了 eve::inventory::InventoryChangeEvent::action, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::inventory::ItemRegistry::find(), eve::inventory::Bag::getId(), index, eve::InvalidArgument, eve::NotFound, eve::Pending, eve::PreconditionViolation, eve::Status::success() , 以及 eve::Result< T >::success().
被这些函数引用 eve::rpg::ShopTransaction::buy(), eve::rpg::QuestReward::claim() , 以及 eve::rpg::WorldInteraction::collectLoot().
◆ prepareRemove()
|
static |
Prepare removal of one exact item quantity without mutation or events.
- 返回
- Pending mutation, or structured failure when the quantity is unavailable. @thread Call on the Bag owning simulation thread.
在文件 InventorySystem.cpp 第 497 行定义.
引用了 countItem(), eve::Diagnostic::error(), eve::Result< T >::failure(), eve::inventory::ItemRegistry::find(), eve::inventory::Bag::getId(), eve::InvalidArgument, itemId, eve::NotFound, eve::Pending, eve::PreconditionViolation, eve::Status::success() , 以及 eve::Result< T >::success().
被这些函数引用 eve::rpg::ShopTransaction::sell().
◆ pushEvent()
|
static |
◆ registerAcceptRule()
|
static |
◆ registerCapacityPolicy()
|
static |
◆ registerChangeHook()
|
static |
◆ registerStackRule()
|
static |
◆ removeAt()
|
static |
Removes at.
在文件 InventorySystem.cpp 第 575 行定义.
引用了 eve::inventory::InventoryChangeEvent::action, eve::inventory::InventoryChangeEvent::bagId, eve::inventory::Bag::getId(), eve::inventory::Bag::getSlotCount(), itemId, eve::inventory::InventoryChangeEvent::itemId, eve::inventory::InventoryChangeEvent::quantity, s, eve::inventory::InventoryChangeEvent::slot , 以及 eve::inventory::Bag::slots().
被这些函数引用 eve::inventory::Bag::removeAt().
◆ removeItem()
|
static |
在文件 InventorySystem.cpp 第 551 行定义.
引用了 eve::inventory::InventoryChangeEvent::action, eve::inventory::InventoryChangeEvent::bagId, eve::inventory::Bag::getId(), eve::inventory::Bag::getSlotCount(), itemId, eve::inventory::InventoryChangeEvent::itemId, eve::inventory::InventoryChangeEvent::quantity, removed, s , 以及 eve::inventory::Bag::slots().
被这些函数引用 eve::inventory::Bag::removeItem().
◆ splitStack()
|
static |
Split stack.
在文件 InventorySystem.cpp 第 652 行定义.
引用了 eve::inventory::InventoryChangeEvent::action, eve::inventory::InventoryChangeEvent::bagId, from, eve::inventory::Bag::getId(), eve::inventory::Bag::getSlotCount(), eve::inventory::InventoryChangeEvent::itemId, nextInstanceId(), eve::inventory::InventoryChangeEvent::otherSlot, eve::inventory::InventoryChangeEvent::quantity, eve::inventory::InventoryChangeEvent::slot, eve::inventory::Bag::slots() , 以及 to.
被这些函数引用 eve::inventory::Bag::splitStack().
◆ swapSlots()
|
static |
Swap slots.
在文件 InventorySystem.cpp 第 593 行定义.
引用了 eve::inventory::InventoryChangeEvent::action, eve::inventory::InventoryChangeEvent::bagId, eve::inventory::Bag::getId(), eve::inventory::Bag::getSlotCount(), eve::inventory::InventoryChangeEvent::otherSlot, eve::inventory::InventoryChangeEvent::slot , 以及 eve::inventory::Bag::slots().
被这些函数引用 moveSlot() , 以及 eve::inventory::Bag::swapSlots().
◆ transfer()
|
static |
Transfer.
在文件 InventorySystem.cpp 第 677 行定义.
引用了 eve::inventory::InventoryChangeEvent::action, addItem(), eve::inventory::InventoryChangeEvent::bagId, canAdd(), countItem(), from, itemId, eve::inventory::InventoryChangeEvent::itemId, n, eve::inventory::InventoryChangeEvent::otherBagId, eve::inventory::InventoryChangeEvent::quantity, s , 以及 to.
◆ transferSlot()
|
static |
Transfer slot.
在文件 InventorySystem.cpp 第 717 行定义.
引用了 eve::inventory::InventoryChangeEvent::action, addItem(), eve::inventory::InventoryChangeEvent::bagId, canAdd(), eve::inventory::ItemRegistry::find(), from, itemId, eve::inventory::InventoryChangeEvent::itemId, eve::inventory::ItemDefinition::maxStack, n, nextInstanceId(), eve::inventory::InventoryChangeEvent::otherBagId, eve::inventory::InventoryChangeEvent::otherSlot, eve::inventory::InventoryChangeEvent::quantity, s, eve::inventory::InventoryChangeEvent::slot , 以及 to.
◆ unequipToBag()
|
static |
Unequip to bag.
在文件 InventorySystem.cpp 第 920 行定义.
引用了 eve::inventory::InventoryChangeEvent::action, addItem(), eve::inventory::InventoryChangeEvent::bagId, canAdd(), eve::inventory::InventoryChangeEvent::equipSlot, eve::inventory::Bag::getId(), eve::inventory::Bag::getSlotCount(), itemId, eve::inventory::ItemStack::itemId, eve::inventory::InventoryChangeEvent::itemId, nextInstanceId(), eve::inventory::InventoryChangeEvent::quantity, eve::inventory::InventoryChangeEvent::slot, eve::inventory::Bag::slots() , 以及 eve::inventory::EquipmentSet::stackAt().
◆ unregisterAcceptRule()
|
static |
◆ unregisterCapacityPolicy()
|
static |
◆ unregisterChangeHook()
|
static |
◆ unregisterStackRule()
|
static |
◆ usedSlotCount()
|
static |
◆ usedVolume()
|
static |
Used volume.
在文件 InventorySystem.cpp 第 855 行定义.
引用了 eve::inventory::ItemRegistry::find(), s, eve::inventory::Bag::slots(), v , 以及 eve::inventory::ItemDefinition::volume.
被这些函数引用 ensureBuiltins() , 以及 eve::inventory::Bag::getUsedVolume().
◆ usedWeight()
|
static |
Used weight.
在文件 InventorySystem.cpp 第 844 行定义.
引用了 eve::inventory::ItemRegistry::find(), s, eve::inventory::Bag::slots(), w , 以及 eve::inventory::ItemDefinition::weight.
被这些函数引用 ensureBuiltins() , 以及 eve::inventory::Bag::getUsedWeight().
友元及相关函数文档
◆ InventoryResourceAccount
|
friend |
在文件 InventorySystem.h 第 207 行定义.
◆ InventorySaveSession
|
friend |
在文件 InventorySystem.h 第 208 行定义.
该类的文档由以下文件生成:
- src/modules/inventory/InventorySystem.h
- src/modules/inventory/InventorySystem.cpp