载入中...
搜索中...
未找到
eve::inventory::InventorySystem类 参考

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()

int eve::inventory::InventorySystem::addItem ( Bag *  bag,
const std::string &  itemId,
int  quantity 
)
static

返回实际放入数量(可能部分成功)。

在文件 InventorySystem.cpp 第 366 行定义.

引用了 itemId.

被这些函数引用 eve::inventory::Bag::addItem(), transfer(), transferSlot() , 以及 unequipToBag().

◆ canAdd()

bool eve::inventory::InventorySystem::canAdd ( Bag *  bag,
const std::string &  itemId,
int  quantity,
std::string *  reason = nullptr 
)
static

◆ clearBag()

◆ clearEvents()

void eve::inventory::InventorySystem::clearEvents ( )
static

Clears events.

在文件 InventorySystem.cpp 第 292 行定义.

被这些函数引用 eve::inventory::Inventory::clearChangeEvents().

◆ commitAddBatch()

eve::Result< int > eve::inventory::InventorySystem::commitAddBatch ( PreparedInventoryAdd  prepared)
static

Commit one prepared addition and then publish its change events.

参数
preparedPrepared 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()

eve::Result< int > eve::inventory::InventorySystem::commitRemove ( PreparedInventoryRemove  prepared)
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()

int eve::inventory::InventorySystem::countItem ( const Bag *  bag,
const std::string &  itemId 
)
static

Returns the number of item.

在文件 InventorySystem.cpp 第 814 行定义.

引用了 itemId, n, s , 以及 eve::inventory::Bag::slots().

被这些函数引用 eve::inventory::Bag::countItem(), prepareRemove() , 以及 transfer().

◆ ensureBuiltins()

◆ equipFromBag()

◆ events()

◆ findItem()

int eve::inventory::InventorySystem::findItem ( const Bag *  bag,
const std::string &  itemId 
)
static

Finds item.

在文件 InventorySystem.cpp 第 823 行定义.

引用了 eve::inventory::Bag::getSlotCount(), itemId, s , 以及 eve::inventory::Bag::slots().

被这些函数引用 eve::inventory::Bag::findItem().

◆ findItemByTag()

int eve::inventory::InventorySystem::findItemByTag ( const Bag *  bag,
const std::string &  tag 
)
static

◆ hasAcceptRule()

bool eve::inventory::InventorySystem::hasAcceptRule ( const std::string &  name)
static

True when accept rule.

在文件 InventorySystem.cpp 第 100 行定义.

引用了 ensureBuiltins() , 以及 name.

被这些函数引用 eve::inventory::Inventory::hasAcceptRule() , 以及 eve::inventory::InventorySaveSession::prepareRestoreSnapshotJson().

◆ hasCapacityPolicy()

bool eve::inventory::InventorySystem::hasCapacityPolicy ( const std::string &  name)
static

True when capacity policy.

在文件 InventorySystem.cpp 第 114 行定义.

引用了 ensureBuiltins() , 以及 name.

被这些函数引用 eve::inventory::Inventory::hasCapacityPolicy() , 以及 eve::inventory::InventorySaveSession::prepareRestoreSnapshotJson().

◆ hasChangeHook()

bool eve::inventory::InventorySystem::hasChangeHook ( const std::string &  name)
static

True when change hook.

在文件 InventorySystem.cpp 第 138 行定义.

引用了 name.

◆ hasStackRule()

bool eve::inventory::InventorySystem::hasStackRule ( const std::string &  name)
static

True when stack rule.

在文件 InventorySystem.cpp 第 126 行定义.

引用了 ensureBuiltins() , 以及 name.

被这些函数引用 eve::inventory::Inventory::hasStackRule() , 以及 eve::inventory::InventorySaveSession::prepareRestoreSnapshotJson().

◆ moveSlot()

◆ nextInstanceId()

int eve::inventory::InventorySystem::nextInstanceId ( )
static

Next instance id.

在文件 InventorySystem.cpp 第 229 行定义.

被这些函数引用 splitStack(), transferSlot() , 以及 unequipToBag().

◆ pollEvents()

void eve::inventory::InventorySystem::pollEvents ( std::vector< InventoryChangeEvent > &  out)
static

Polls events.

在文件 InventorySystem.cpp 第 287 行定义.

◆ prepareAddBatch()

eve::Result< PreparedInventoryAdd > eve::inventory::InventorySystem::prepareAddBatch ( Bag *  bag,
const std::vector< InventoryItemGrant > &  grants 
)
static

Validate a multi-item addition against a private candidate Bag.

参数
bagBorrowed Bag that must remain alive and unmodified until commit.
grantsExact 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()

eve::Result< PreparedInventoryRemove > eve::inventory::InventorySystem::prepareRemove ( Bag *  bag,
const std::string &  itemId,
int  quantity 
)
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()

void eve::inventory::InventorySystem::pushEvent ( InventoryChangeEvent  ev)
static

Pushes event.

在文件 InventorySystem.cpp 第 285 行定义.

被这些函数引用 eve::inventory::EquipmentSet::clearSlot().

◆ registerAcceptRule()

void eve::inventory::InventorySystem::registerAcceptRule ( const std::string &  name,
AcceptFn  fn 
)
static

Registers accept rule.

在文件 InventorySystem.cpp 第 93 行定义.

引用了 fn , 以及 name.

被这些函数引用 ensureBuiltins().

◆ registerCapacityPolicy()

void eve::inventory::InventorySystem::registerCapacityPolicy ( const std::string &  name,
CapacityFn  fn 
)
static

Registers capacity policy.

在文件 InventorySystem.cpp 第 105 行定义.

引用了 fn , 以及 name.

被这些函数引用 ensureBuiltins().

◆ registerChangeHook()

void eve::inventory::InventorySystem::registerChangeHook ( const std::string &  name,
ChangeHook  fn 
)
static

Registers change hook.

在文件 InventorySystem.cpp 第 131 行定义.

引用了 fn , 以及 name.

◆ registerStackRule()

void eve::inventory::InventorySystem::registerStackRule ( const std::string &  name,
StackFn  fn 
)
static

Registers stack rule.

在文件 InventorySystem.cpp 第 119 行定义.

引用了 fn , 以及 name.

被这些函数引用 ensureBuiltins().

◆ removeAt()

◆ removeItem()

◆ splitStack()

◆ swapSlots()

◆ transfer()

int eve::inventory::InventorySystem::transfer ( Bag *  from,
Bag *  to,
const std::string &  itemId,
int  quantity 
)
static

◆ transferSlot()

◆ unequipToBag()

◆ unregisterAcceptRule()

void eve::inventory::InventorySystem::unregisterAcceptRule ( const std::string &  name)
static

Unregisters accept rule.

在文件 InventorySystem.cpp 第 98 行定义.

引用了 name.

◆ unregisterCapacityPolicy()

void eve::inventory::InventorySystem::unregisterCapacityPolicy ( const std::string &  name)
static

Unregisters capacity policy.

在文件 InventorySystem.cpp 第 110 行定义.

引用了 name.

◆ unregisterChangeHook()

void eve::inventory::InventorySystem::unregisterChangeHook ( const std::string &  name)
static

Unregisters change hook.

在文件 InventorySystem.cpp 第 136 行定义.

引用了 name.

◆ unregisterStackRule()

void eve::inventory::InventorySystem::unregisterStackRule ( const std::string &  name)
static

Unregisters stack rule.

在文件 InventorySystem.cpp 第 124 行定义.

引用了 name.

◆ usedSlotCount()

int eve::inventory::InventorySystem::usedSlotCount ( const Bag *  bag)
static

Used slot count.

在文件 InventorySystem.cpp 第 866 行定义.

引用了 n, s , 以及 eve::inventory::Bag::slots().

被这些函数引用 eve::inventory::Bag::getUsedSlotCount().

◆ usedVolume()

float eve::inventory::InventorySystem::usedVolume ( const Bag *  bag)
static

◆ usedWeight()

float eve::inventory::InventorySystem::usedWeight ( const Bag *  bag)
static

友元及相关函数文档

◆ InventoryResourceAccount

friend class InventoryResourceAccount
friend

在文件 InventorySystem.h 第 207 行定义.

◆ InventorySaveSession

friend class InventorySaveSession
friend

在文件 InventorySystem.h 第 208 行定义.


该类的文档由以下文件生成: