init
This commit is contained in:
49
Content/Blueprints/BP_DropItemInvComp.md
Normal file
49
Content/Blueprints/BP_DropItemInvComp.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# BP_DropItemInvComp
|
||||
|
||||
## 基本信息
|
||||
- **类型**: Blueprint (ActorComponent)
|
||||
- **父类**: BP_InventoryComp
|
||||
- **源文件**: /Game/Blueprints/Playground/BP_DropItemInvComp.BP_DropItemInvComp
|
||||
- **模块**: Content
|
||||
|
||||
## 功能概述
|
||||
BP_DropItemInvComp 是掉落物品库存组件,继承 BP_InventoryComp 并增加了一个 FName 类型的 `Item` 变量,用于指定该掉落物包含什么物品类型。适用于可拾取的掉落物 Actor。
|
||||
|
||||
## 设计用意
|
||||
BP_DropItemInvComp 将 BP_InventoryComp 的通用库存功能特化为"掉落物"用途。通过 Item 变量指定掉落物的物品类型,在 BeginPlay 时自动调用继承的 CreateItemInternal 创建物品,结合继承的 IInventory 接口实现支持玩家通过 ReceiveItem 拾取。这种设计使掉落物 Actor 只需添加一个组件并设置一个变量即可完整支持物品掉落和拾取流程。
|
||||
|
||||
## 职责范围
|
||||
BP_DropItemInvComp 负责掉落物品的自动创建和作为可拾取物品容器运行。掉落物的物理表现由所在的 Actor 负责,复杂的物品行为由物品类型配置决定。
|
||||
|
||||
## 项目内依赖
|
||||
| 依赖项 | 关系 | 源文件 |
|
||||
|--------|------|--------|
|
||||
| BP_InventoryComp | 父类 | /Game/Blueprints/Playground/BP_InventoryComp |
|
||||
|
||||
## 对外接口
|
||||
- **蓝图变量**(is_instance_editable):
|
||||
- `Item` (FName) -- 掉落物品的类型名称,对应数据表中物品行的 RowName。在组件实例上设置,指定该掉落物包含什么物品
|
||||
- **继承自 BP_InventoryComp 的全部接口**:
|
||||
- `DefaultContainer` -- 底层物品容器引用
|
||||
- `ViewCache` (TArray<FItemView>) -- 物品视图缓存
|
||||
- `OnViewChanged` -- 视图变化委托
|
||||
- `UpdateViewCache()` -- 刷新视图缓存
|
||||
- `CreateItemInternal(FName ItemType, int32 Count) -> bool` -- 创建物品
|
||||
- **继承自 BP_InventoryComp 的 IInventory 接口实现**:
|
||||
- `GetItemViews()`、`GetItemViewByID()`、`GetItemCount()` -- 查询接口
|
||||
- `RequestMoveItem(ID, TargetInventory)` -- 请求移出物品(掉落物被拾取时调用)
|
||||
- `ReceiveItem(ID, SourceContainer)` -- 从其他容器接收物品(拾取验证场景使用)
|
||||
- **EventGraph**:含 2 个事件和 7 个节点,在 BeginPlay 时根据 `Item` 变量自动调用 CreateItemInternal
|
||||
|
||||
## 使用方法
|
||||
- 作为 ActorComponent 添加到掉落物 Actor 上
|
||||
- 在组件实例上设置 `Item` 变量为数据表中物品的 RowName(FName 类型)
|
||||
- 在 BeginPlay 事件中自动调用 `CreateItemInternal(Item, 1)` 创建物品,实现掉落物生成
|
||||
- 可以通过设置 `DefaultContainer` 覆盖默认的 BP_DefaultContainer
|
||||
- 玩家拾取时,通过 IInventory::RequestMoveItem 将物品从掉落物容器转移至玩家库存
|
||||
- 掉落物的物理外观由所在的 Actor 负责,本组件仅处理物品数据的创建和转移
|
||||
- 继承自 BP_InventoryComp,所有库存管理功能均可用
|
||||
|
||||
## 用例
|
||||
- 掉落物 Actor 的库存组件,在运行时自动生成配置的物品
|
||||
- 其父类 BP_InventoryComp 同时被 WBP_InventoryView 引用以显示物品列表
|
||||
Reference in New Issue
Block a user