15#include <unordered_map>
22class InventoryResourceAccount;
23class InventorySaveSession;
84 std::function<bool(
const Bag &bag,
const ItemDefinition &def,
int quantity, std::string *reason)>;
87 std::function<bool(
const Bag &bag,
const ItemDefinition &def,
int quantity, std::string *reason)>;
94 static void registerAcceptRule(
const std::string &
name,
AcceptFn fn);
96 static void unregisterAcceptRule(
const std::string &
name);
98 static bool hasAcceptRule(
const std::string &
name);
103 static void unregisterCapacityPolicy(
const std::string &
name);
105 static bool hasCapacityPolicy(
const std::string &
name);
108 static void registerStackRule(
const std::string &
name,
StackFn fn);
110 static void unregisterStackRule(
const std::string &
name);
112 static bool hasStackRule(
const std::string &
name);
117 static void unregisterChangeHook(
const std::string &
name);
119 static bool hasChangeHook(
const std::string &
name);
122 static void ensureBuiltins();
125 static bool canAdd(
Bag *bag,
const std::string &
itemId,
int quantity, std::string *reason =
nullptr);
127 static int addItem(
Bag *bag,
const std::string &
itemId,
int quantity);
137 prepareAddBatch(
Bag *bag,
const std::vector<InventoryItemGrant> &grants);
153 prepareRemove(
Bag *bag,
const std::string &
itemId,
int quantity);
160 static int removeItem(
Bag *bag,
const std::string &
itemId,
int quantity);
162 static int removeAt(
Bag *bag,
int slot,
int quantity);
164 static bool swapSlots(
Bag *bag,
int slotA,
int slotB);
166 static bool moveSlot(
Bag *bag,
int fromSlot,
int toSlot);
168 static bool splitStack(
Bag *bag,
int slot,
int quantity,
int toSlot);
172 static int transferSlot(
Bag *
from,
int fromSlot,
Bag *
to,
int quantity);
175 static int countItem(
const Bag *bag,
const std::string &
itemId);
177 static int findItem(
const Bag *bag,
const std::string &
itemId);
179 static int findItemByTag(
const Bag *bag,
const std::string &
tag);
181 static float usedWeight(
const Bag *bag);
183 static float usedVolume(
const Bag *bag);
185 static int usedSlotCount(
const Bag *bag);
187 static void clearBag(
Bag *bag);
190 static bool equipFromBag(
EquipmentSet *eq,
const std::string &equipSlot,
Bag *bag,
int bagSlot);
192 static bool unequipToBag(
EquipmentSet *eq,
const std::string &equipSlot,
Bag *bag);
197 static void pollEvents(std::vector<InventoryChangeEvent> &out);
199 static void clearEvents();
201 static const std::vector<InventoryChangeEvent> &
events();
204 static int nextInstanceId();
210 static void ensureNextInstanceIdAbove(
int usedInstanceId)
noexcept;
215 std::string *reason);
216 static bool checkCapacity(
const Bag &bag,
const ItemDefinition &def,
int quantity,
217 std::string *reason);
220 static int addItemImpl(
Bag *bag,
const std::string &
itemId,
int quantity,
bool publish);
222 static std::unordered_map<std::string, AcceptFn> &acceptRules();
223 static std::unordered_map<std::string, CapacityFn> &capacityPolicies();
224 static std::unordered_map<std::string, StackFn> &stackRules();
225 static std::unordered_map<std::string, ChangeHook> &changeHooks();
226 static std::vector<InventoryChangeEvent> &eventQueue();
227 static int &instanceCounter();
228 static bool &builtinsReady();
229 static bool &changeHooksSuppressed();
230 static std::unique_ptr<Bag> cloneBag(
const Bag &
source);
231 static bool bagsEqual(
const Bag &
target,
const Bag &baseline);
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
HexCoordinates to
Cell the unit walks towards on this segment.
Move-only, checked operation results for the common layer.
const UnitySourceAsset & source
Move-only operation result carrying either a value or Status.
EVENGINE_API_FOUNDATION public API.
Adapts one Bag's item quantities to the common resource protocol.
Coordinates persistent inventory owners without duplicating their live state.
EVENGINE_API_FOUNDATION public API.
std::function< void(const InventoryChangeEvent &ev)> ChangeHook
std::function< bool(const Bag &bag, const ItemDefinition &def, int quantity, std::string *reason)> CapacityFn
std::function< bool(const Bag &bag, const ItemDefinition &def, int quantity, std::string *reason)> AcceptFn
std::function< bool(const ItemStack &a, const ItemStack &b, const ItemDefinition &def)> StackFn
Move-only, validated inventory state prepared for one Bag.
PreparedInventoryAdd()
Prepared inventory add.
~PreparedInventoryAdd()
Prepared inventory add.
PreparedInventoryAdd(PreparedInventoryAdd &&) noexcept
Prepared inventory add.
Move-only, validated inventory removal prepared for one Bag.
~PreparedInventoryRemove()
Prepared inventory remove.
PreparedInventoryRemove(PreparedInventoryRemove &&) noexcept
Prepared inventory remove.
PreparedInventoryRemove()
Prepared inventory remove.
运行时容器:固定格数的背包 / 箱子 / 商店栏等。 行为由 InventorySystem 提供;本类暴露便于脚本绑定的薄封装方法。
SettlementPipeline::Stage fn
一次成功库存变更的事件(供脚本 poll / C++ hook)。
One exact item quantity requested by an atomic inventory batch.
物品模板(进程级注册表中的定义,不含运行时数量)。
容器中的一格堆叠(空槽:itemId 为空或 quantity <= 0)。