update
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
- **类型**: Blueprint (UObject)
|
||||
- **父类**: UDefaultContainer
|
||||
- **源文件**: /Game/Blueprints/Playground/BP_DefaultContainer.BP_DefaultContainer
|
||||
- **模块**: Content
|
||||
- **模块**: Content/Blueprints/Playground
|
||||
|
||||
## 功能概述
|
||||
BP_DefaultContainer 是 UDefaultContainer 的蓝图子类,作为物品系统的默认容器在蓝图层中使用。无额外自定义变量,直接使用 C++ 父类的完整 IItemContainer 实现,提供 CreateItem、GetItemViews、MoveItem 等物品操作接口。
|
||||
@@ -21,25 +21,36 @@ BP_DefaultContainer 作为物品容器的蓝图实例化版本,负责在编辑
|
||||
| UDefaultContainer | 父类 | Item 插件 |
|
||||
| IItemContainer | 间接实现 | Item 插件 |
|
||||
|
||||
## 对外接口
|
||||
- **继承自 UDefaultContainer(即 IItemContainer 接口)的全部 BlueprintCallable 函数**:
|
||||
- `GetItemViews() const -> TArray<FItemView>` -- 返回容器中所有物品视图列表
|
||||
- `GetItemViewByID(const FGuid& ItemID) const -> FItemView` -- 按物品 ID 获取单个物品视图
|
||||
- `GetItemCount() const -> int32` -- 返回当前容器中的物品数量
|
||||
- `MoveItem(const FGuid& ItemID, const TScriptInterface<IItemContainer>& TargetContainer) -> bool` -- 将物品移动到目标容器(BlueprintAuthorityOnly)
|
||||
- `CreateItem(FName ItemType, TArray<FGuid>& NewItemIDs, int32 Count=1) -> bool` -- 按 ItemType 创建物品(BlueprintAuthorityOnly)
|
||||
- `GetItemProperty(FGuid ItemID, FName PropertyName, int32& Value) -> bool` -- 读取物品动态属性(CustomThunk,属性类型自动匹配)
|
||||
- `SetItemProperty(FGuid ItemID, FName PropertyName, int32 Value)` -- 写入物品动态属性(CustomThunk)
|
||||
- **无自定义蓝图变量或函数**(MCP: variables=[], functions=[]):纯父类能力透传,所有接口由 UDefaultContainer C++ 层实现
|
||||
## 外部视角
|
||||
|
||||
BP_DefaultContainer 是 UDefaultContainer(Item 插件 C++ 类)的蓝图子类,从外部调用者视角:
|
||||
|
||||
**接口概览**
|
||||
- 无自定义变量或函数,所有接口继承自 C++ 父类 UDefaultContainer
|
||||
- UDefaultContainer 实现 IItemContainer 接口,提供:CreateItem、GetItemViews、MoveItem、RemoveItem 等物品操作
|
||||
- 本身是纯配置层——使 UDefaultContainer 在蓝图中可引用
|
||||
|
||||
**外部交互方式**
|
||||
- 作为 BP_InventoryComp 的 DefaultContainer 变量默认实例
|
||||
- 其他蓝图通过 BP_InventoryComp 间接访问 BP_DefaultContainer 的物品操作接口
|
||||
|
||||
**EventGraph 事件**
|
||||
|
||||
| 事件 | 类型 | 触发时机 | 行为 |
|
||||
|------|------|----------|------|
|
||||
| (无) | — | — | EventGraph 为空,所有功能由 C++ 父类实现 |
|
||||
|
||||
## 使用方法
|
||||
- 作为 UObject 资产创建并保存在 /Game/Blueprints/Playground/ 路径下
|
||||
- 被 BP_InventoryComp 的 `DefaultContainer` 变量引用,作为物品的实际存储容器
|
||||
- 通过 IItemContainer 接口的所有 BlueprintCallable 函数进行物品操作
|
||||
- 实际存储逻辑由 C++ 父类 UDefaultContainer 的 `TArray<TUniquePtr<FItemInstance>> Items` 处理
|
||||
- BP_DefaultContainer 存在的意义是提供一个蓝图可引用的资产版本,方便在编辑器中直接拖拽配置
|
||||
- 无需在蓝图层面编写任何逻辑(functions=[]),完全依赖父类实现
|
||||
|
||||
BP_DefaultContainer 在项目中的典型调用流程:
|
||||
|
||||
- **初始化流程** — BP_InventoryComp.BeginPlay → 创建 BP_DefaultContainer 实例 → 存入 DefaultContainer 变量 → 外部系统通过 BP_InventoryComp 间接调用 IItemContainer 接口
|
||||
|
||||
## 用例
|
||||
- BP_InventoryComp 的 `DefaultContainer` 变量默认值,作为库存组件的底层存储
|
||||
- 任何需要 IItemContainer 接口的地方均可引用此资产
|
||||
|
||||
| 引用方 | 路径 | 用途 |
|
||||
|--------|------|------|
|
||||
| BP_InventoryComp | `/Game/Blueprints/Playground/BP_InventoryComp` | 作为默认容器实例,管理物品存储 |
|
||||
| BP_Bomb | `/Game/Blueprints/Playground/BP_Bomb` | 容器引用,用于炸弹物品生命周期 |
|
||||
| BP_ItemTrap | `/Game/Blueprints/Playground/BP_ItemTrap` | 容器引用,用于陷阱物品管理 |
|
||||
| BP_Barrel | `/Game/Blueprints/Playground/BP_Barrel` | 容器引用,用于木桶物品管理 |
|
||||
|
||||
Reference in New Issue
Block a user