14#include <unordered_map>
19class InventorySaveSession;
36 std::string
getId()
const {
return id_; }
38 void setId(
const std::string &
id) { id_ =
id; }
41 std::string
getKind()
const {
return kind_; }
48 void setSlotCount(
int slotCount);
73 void clearAcceptTags();
75 void addAcceptTag(
const std::string &
tag);
77 int getAcceptTagCount()
const;
79 std::string getAcceptTag(
int index)
const;
82 void clearRejectTags();
84 void addRejectTag(
const std::string &
tag);
86 int getRejectTagCount()
const;
88 std::string getRejectTag(
int index)
const;
91 void setExtra(
const std::string &
key,
const std::string &
value);
93 std::string getExtra(
const std::string &
key,
const std::string &fallback = {})
const;
96 bool canAddItem(
const std::string &
itemId,
int quantity);
98 std::string canAddItemReason(
const std::string &
itemId,
int quantity);
100 int addItem(
const std::string &
itemId,
int quantity);
102 int removeItem(
const std::string &
itemId,
int quantity);
104 int removeAt(
int slot,
int quantity);
106 bool swapSlots(
int slotA,
int slotB);
108 bool moveSlot(
int fromSlot,
int toSlot);
110 bool splitStack(
int slot,
int quantity,
int toSlot);
112 int countItem(
const std::string &
itemId)
const;
114 int findItem(
const std::string &
itemId)
const;
116 int findItemByTag(
const std::string &
tag)
const;
118 float getUsedWeight()
const;
120 float getUsedVolume()
const;
122 int getUsedSlotCount()
const;
128 bool isSlotEmpty(
int slot)
const;
130 std::string getSlotItemId(
int slot)
const;
132 int getSlotQuantity(
int slot)
const;
134 int getSlotInstanceId(
int slot)
const;
136 float getSlotDurability(
int slot)
const;
138 void setSlotDurability(
int slot,
float durability);
140 std::string getSlotProp(
int slot,
const std::string &
key,
const std::string &fallback = {})
const;
142 void setSlotProp(
int slot,
const std::string &
key,
const std::string &
value);
144 bool slotHasTag(
int slot,
const std::string &
tag)
const;
146 void addSlotTag(
int slot,
const std::string &
tag);
150 const std::vector<ItemStack> &
slots()
const {
return slots_; }
152 std::vector<ItemStack> &
slots() {
return slots_; }
154 const std::vector<std::string> &
acceptTags()
const {
return acceptTags_; }
156 const std::vector<std::string> &
rejectTags()
const {
return rejectTags_; }
163 std::string kind_ =
"backpack";
164 float maxWeight_ = 0.f;
165 float maxVolume_ = 0.f;
166 std::string acceptRule_ =
"default";
167 std::string capacityPolicy_ =
"slotsAndWeight";
168 std::string stackRule_ =
"sameItem";
169 std::vector<std::string> acceptTags_;
170 std::vector<std::string> rejectTags_;
171 std::vector<ItemStack> slots_;
172 std::unordered_map<std::string, std::string> extra_;
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Share string attribute map operations through the Windows Foundation DLL.
std::string getId() const
容器 id(变更事件定位用)。
float getMaxVolume() const
Returns the max volume.
const std::vector< ItemStack > & slots() const
Slots.
const std::vector< std::string > & rejectTags() const
Reject tags.
std::vector< ItemStack > & slots()
Slots.
float getMaxWeight() const
重量 / 体积上限(容量策略用)。
const std::vector< std::string > & acceptTags() const
Accept tags.
std::string getStackRule() const
Returns the stack rule.
void setCapacityPolicy(const std::string &name)
Sets the capacity policy.
void setKind(const std::string &kind)
Sets the kind.
std::string getKind() const
容器种类(bag / chest / shop 等)。
void setAcceptRule(const std::string &name)
Sets the accept rule.
void setId(const std::string &id)
Sets the id.
int getSlotCount() const
格数。
std::string getAcceptRule() const
接受规则 / 容量策略 / 堆叠规则名。
void setMaxVolume(float v)
Sets the max volume.
void setMaxWeight(float w)
Sets the max weight.
std::string getCapacityPolicy() const
Returns the capacity policy.
Bag & operator=(const Bag &)=delete
void setStackRule(const std::string &name)
Sets the stack rule.
Coordinates persistent inventory owners without duplicating their live state.
EVENGINE_API_FOUNDATION public API.
运行时容器:固定格数的背包 / 箱子 / 商店栏等。 行为由 InventorySystem 提供;本类暴露便于脚本绑定的薄封装方法。