载入中...
搜索中...
未找到
ItemTypes.h
浏览该文件的文档.
1#pragma once
2
3// 背包模块的核心数据结构:物品定义、运行时堆叠、变更事件。
4// 全部 key 使用字符串,便于 JSON 配置与跨版本兼容。
5
6#include <string>
7#include <unordered_map>
8#include <vector>
9
10namespace eve::inventory {
11
14 std::string id;
15 std::string displayName;
16 int maxStack = 1;
17 float weight = 0.f;
18 float volume = 0.f;
19 std::vector<std::string> tags;
20 std::string category;
22 std::string equipSlot;
23 std::unordered_map<std::string, std::string> extra;
24
25 bool hasTag(const std::string &tag) const;
26 std::string getExtra(const std::string &key, const std::string &fallback = {}) const;
27};
28
30struct ItemStack {
31 int instanceId = 0;
32 std::string itemId;
33 int quantity = 0;
34 float durability = -1.f;
35 std::unordered_map<std::string, std::string> props;
36 std::vector<std::string> tags;
37
38 bool empty() const { return itemId.empty() || quantity <= 0; }
39 void clear();
40 bool hasTag(const std::string &tag) const;
41 std::string getProp(const std::string &key, const std::string &fallback = {}) const;
42 void setProp(const std::string &key, const std::string &value);
43};
44
47 std::string action;
48 std::string bagId;
49 std::string otherBagId;
50 std::string itemId;
51 int quantity = 0;
52 int slot = -1;
53 int otherSlot = -1;
54 std::string equipSlot;
55};
56
57} // namespace eve::inventory
std::string value
运行时容器:固定格数的背包 / 箱子 / 商店栏等。 行为由 InventorySystem 提供;本类暴露便于脚本绑定的薄封装方法。
Definition Bag.cpp:6
一次成功库存变更的事件(供脚本 poll / C++ hook)。
Definition ItemTypes.h:46
std::string action
add/remove/move/swap/split/merge/transfer/equip/unequip
Definition ItemTypes.h:47
物品模板(进程级注册表中的定义,不含运行时数量)。
Definition ItemTypes.h:13
std::string equipSlot
非空表示建议装备槽名;是否可装备由 EquipmentSet 槽位配置最终决定。
Definition ItemTypes.h:22
std::unordered_map< std::string, std::string > extra
Definition ItemTypes.h:23
std::vector< std::string > tags
Definition ItemTypes.h:19
bool hasTag(const std::string &tag) const
Definition Item.cpp:11
std::string getExtra(const std::string &key, const std::string &fallback={}) const
Definition Item.cpp:15
容器中的一格堆叠(空槽:itemId 为空或 quantity <= 0)。
Definition ItemTypes.h:30
bool hasTag(const std::string &tag) const
Definition Item.cpp:29
void setProp(const std::string &key, const std::string &value)
Definition Item.cpp:38
std::string getProp(const std::string &key, const std::string &fallback={}) const
Definition Item.cpp:33
std::unordered_map< std::string, std::string > props
Definition ItemTypes.h:35
float durability
< 0 表示不适用
Definition ItemTypes.h:34
std::vector< std::string > tags
Definition ItemTypes.h:36