载入中...
搜索中...
未找到
Inventory.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
10#include "common/Module.h"
11#include "common/Result.h"
12#include "inventory/Bag.h"
13#include "inventory/Equipment.h"
14
15#include <memory>
16#include <string>
17#include <vector>
18
19namespace eve::inventory {
20
21class InventoryControl;
22
25public:
27 // Declared out of line, like the destructor below: the class owns a
28 // unique_ptr<InventoryControl> whose type is only forward declared here, and
29 // a defaulted constructor in the class body has to destroy the members it
30 // already built when a later one throws -- which needs the complete type
31 // (C2027 "can't delete an incomplete type" in the Dawn parity lane).
35 ~Inventory() override;
36
38 int registerItemsFromJson(const std::string &json);
40 void clearItemDefinitions();
42 int getItemDefinitionCount();
44 bool hasItemDefinition(const std::string &itemId);
46 std::string getItemDisplayName(const std::string &itemId);
48 int getItemMaxStack(const std::string &itemId);
50 float getItemWeight(const std::string &itemId);
52 float getItemVolume(const std::string &itemId);
54 std::string getItemCategory(const std::string &itemId);
56 std::string getItemEquipSlot(const std::string &itemId);
58 bool itemHasTag(const std::string &itemId, const std::string &tag);
60 std::string getItemExtra(const std::string &itemId, const std::string &key,
61 const std::string &fallback = {});
62
64 Bag *newBag(int slotCount);
66 EquipmentSet *newEquipmentSet();
67
69 int transferItem(Bag *from, Bag *to, const std::string &itemId, int quantity);
71 int transferSlot(Bag *from, int fromSlot, Bag *to, int quantity);
72
74 bool hasAcceptRule(const std::string &name);
76 bool hasCapacityPolicy(const std::string &name);
78 bool hasStackRule(const std::string &name);
79
81 void clearChangeEvents();
83 int getChangeEventCount() const;
85 std::string getChangeEventAction(int index) const;
87 std::string getChangeEventBagId(int index) const;
89 std::string getChangeEventOtherBagId(int index) const;
91 std::string getChangeEventItemId(int index) const;
93 int getChangeEventQuantity(int index) const;
95 int getChangeEventSlot(int index) const;
97 int getChangeEventOtherSlot(int index) const;
99 std::string getChangeEventEquipSlot(int index) const;
100
119 [[nodiscard]] eve::Result<void> publishGameplay(const std::string &instanceId, const std::string &ownerId, Bag *bag,
120 EquipmentSet *equipment = nullptr);
122 [[nodiscard]] eve::Result<void> unpublishGameplay(const std::string &instanceId);
124 void clearGameplayControls();
126 [[nodiscard]] int gameplayControlCount() const;
128 [[nodiscard]] std::vector<std::string> gameplayInstances() const;
129
130private:
132 std::unique_ptr<InventoryControl> gameplay_;
133};
134
135} // namespace eve::inventory
LogicalId itemId
std::string from
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
std::uint32_t key
HexCoordinates to
Cell the unit walks towards on this segment.
Definition HexUnits.cpp:64
std::string name
const std::string * tag
Move-only, checked operation results for the common layer.
uint32_t index
EVENGINE_API_FOUNDATION public API.
Definition Module.h:46
Move-only operation result carrying either a value or Status.
Definition Result.h:155
格子型物品容器(脚本可直接操作)。
Definition Bag.h:21
EVENGINE_API_FOUNDATION public API.
Definition Equipment.h:19
背包模块(eve.Inventory)。
Definition Inventory.h:24
运行时容器:固定格数的背包 / 箱子 / 商店栏等。 行为由 InventorySystem 提供;本类暴露便于脚本绑定的薄封装方法。