Files
loneseDocument/Content/Blueprints/BP_ItemTrap.md
meishibiezb a8bdf281ff update
2026-06-05 03:01:15 +08:00

66 lines
2.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# BP_ItemTrap
## 基本信息
- **类型**: Blueprint (Actor)
- **父类**: Actor
- **源文件**: /Game/Blueprints/Playground/BP_ItemTrap.BP_ItemTrap
- **模块**: Content/Blueprints/Playground
## 功能概述
物品陷阱 Actor当触发时通过 GiveItems 函数向角色发放物品。持有 Containerinterface 类型)变量引用容器接口,与 BP_DefaultContainer 和 BP_InventoryComp 协作。
## 设计用意
Playground 中用于测试"触发式物品发放"机制的 Actor验证容器接口Container interface在实际游戏物体上的挂载和调用流程。
## 职责范围
- 持有容器接口引用Container variable, interface 类型)
- 通过 GiveItems 函数发放物品
- 通过 EventGraph4 事件, 9 节点)处理触发逻辑
## 项目内依赖
| 依赖项 | 关系 | 源文件 |
|--------|------|--------|
| BP_NewChar | 引用 | /Game/Blueprints/BP_NewChar |
| BP_InventoryComp | 引用 | /Game/Blueprints/Playground/BP_InventoryComp |
| BP_DefaultContainer | 引用 | /Game/Blueprints/Playground/BP_DefaultContainer |
## 外部视角
BP_ItemTrap 是 Actor 的子类,从外部调用者视角:
**公开属性(蓝图可读写)**
- `Container`IItemContainer 接口引用)— 关联的物品容器
**自定义函数**
- `GiveItems()` — 发放物品给目标角色
**核心行为**
- 被触发时调用 GiveItems 向 BP_NewChar 发放物品
- 通过 Container 接口引用操作 BP_DefaultContainer
**EventGraph 事件**
| 事件 | 类型 | 触发时机 | 行为 |
|------|------|----------|------|
| `事件开始运行` | 原生覆盖 (BeginPlay) | Actor 生成时由引擎自动触发 | 创建 BP_DefaultContainer → 存入 Container 变量 |
| `事件Actor开始重叠` | 原生覆盖 (OnActorBeginOverlap) | 其他 Actor 进入触发区域 | 预留(当前无连线逻辑) |
| `事件Tick` | 原生覆盖 | 每帧 | 调用 GiveItems 发放物品 |
| `事件RequestMoveItem` | 接口事件 (来自 Inventory 系统) | Inventory 系统请求移动物品时 | 通过 Container 获取容器 → ReceiveItem 接收物品 |
**外部交互方式**
- 放置在 Playground 关卡中作为触发式陷阱
- 玩家进入触发区域时自动发放物品
## 使用方法
BP_ItemTrap 在项目中的典型调用流程:
- **陷阱初始化流程** — BeginPlay → 创建 BP_DefaultContainer → 存入 Container 变量 → 物品准备就绪
- **物品发放流程** — Tick 每帧检测(或自定义触发)→ GiveItems → 从 Container 创建物品 → 通过 IInventory 接口发放到 BP_NewChar 的 InventoryComp
## 用例
| 引用方 | 路径 | 用途 |
|--------|------|------|
| Playground | `/Game/地图关卡/Playground` | 关卡中的物品陷阱,演示触发式物品发放 |