update
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
- **类型**: Blueprint (Actor)
|
||||
- **父类**: Actor
|
||||
- **源文件**: /Game/Blueprints/Playground/BP_Bomb.BP_Bomb
|
||||
- **模块**: Content
|
||||
- **模块**: Content/Blueprints/Playground
|
||||
|
||||
## 功能概述
|
||||
BP_Bomb 是物品系统和追踪器系统的交互核心示例 Actor。它结合了 IItemContainer(物品容器接口)、UItemTracer(物品追踪器)和 Owner 检测,演示了物品在 Actor 之间的完整生命周期:创建、追踪、转移和响应。
|
||||
@@ -21,26 +21,45 @@ BP_Bomb 负责演示物品+追踪器的完整交互流程,包括物品创建
|
||||
| IItemContainer | 持有 (ItemContainer) | Item 插件 |
|
||||
| UItemTracer | 持有 (ItemLocation) | Item 插件 |
|
||||
|
||||
## 对外接口
|
||||
- **蓝图函数**:
|
||||
- `GetContainer() -> TScriptInterface<IItemContainer>` -- 返回本 Actor 持有的物品容器接口,用于外部获取容器的物品操作能力
|
||||
- `FindActorInOuterChain(UObject* Obj) -> AActor*` -- 在给定对象的 Outer 链中查找第一个 AActor,蓝图版本的 Outer 遍历(等同于 C++ UItemTracer::FindActorInOuterChain 的蓝图实现)
|
||||
- **蓝图变量**(均为 is_instance_editable):
|
||||
- `ItemContainer` (TScriptInterface<IItemContainer>) -- 物品容器接口引用,提供 CreateItem、MoveItem、GetItemViews 等所有物品操作
|
||||
- `Current Owner` (UObject*) -- 当前持有者对象引用,用于追踪物品在哪个 Actor 身上
|
||||
- `ItemLocation` (UItemTracer*) -- 物品追踪器引用,持有 `OnItemMoved` 委托(FOnItemMoved),用于监听物品位置变化
|
||||
- `Item ID` (FGuid) -- 追踪的物品 ID,用于跨容器识别和追踪物品
|
||||
- **EventGraph**:含 5 个事件和 44 个节点,处理物品生命周期演示逻辑
|
||||
## 外部视角
|
||||
|
||||
BP_Bomb 是 Actor 的子类,从外部调用者视角:
|
||||
|
||||
**公开属性(蓝图可读写)**
|
||||
- `ItemContainer`(IItemContainer 接口引用)— 持有的物品容器
|
||||
- `Current Owner`(Object*)— 当前拥有者
|
||||
- `ItemLocation`(UItemTracer*)— 物品位置追踪器
|
||||
- `Item ID`(Guid)— 追踪的物品 GUID
|
||||
|
||||
**自定义函数**
|
||||
- `GetContainer()` → `IItemContainer` — 获取当前持有的容器接口
|
||||
- `FindActorInOuterChain(Object*)` → `Actor*` — 沿 Outer 链向上查找 Actor
|
||||
|
||||
**外部交互方式**
|
||||
- 放置在 Playground 关卡中作为可交互对象
|
||||
- 演示物品系统核心流程:创建 → 追踪 → 转移 → 响应
|
||||
- 通过 ItemLocation(UItemTracer)绑定 OnItemMoved 委托,检测物品跨容器转移
|
||||
|
||||
**EventGraph 事件**
|
||||
|
||||
| 事件 | 类型 | 触发时机 | 行为 |
|
||||
|------|------|----------|------|
|
||||
| `事件开始运行` | 原生覆盖 (BeginPlay) | Actor 生成时由引擎自动触发 | 通过 GetContainer 获取容器 → CreateItem 创建炸弹物品 → GetItemProperty 获取 ItemTracer → 存入 ItemLocation → 存入 ItemID |
|
||||
| `事件Actor开始重叠` | 原生覆盖 (OnActorBeginOverlap) | 其他 Actor 进入重叠区域 | 预留(当前无连线逻辑) |
|
||||
| `事件Tick` | 原生覆盖 | 每帧 | Switch Has Authority → 服务器端逻辑处理 |
|
||||
| `On Component Hit (Sphere)` | 组件绑定事件 | 球形碰撞体被击中时 | Switch Has Authority → 验证 ItemLocation 有效 → 按类获取 BP_InventoryComp → RequestMoveItem 请求物品移动 |
|
||||
| `事件RequestMoveItem` | 接口事件 (来自 Inventory 系统) | Inventory 系统请求移动物品时 | 通过 GetContainer 获取容器 → ReceiveItem 接收物品 |
|
||||
|
||||
## 使用方法
|
||||
- 作为示例 Actor 放置到关卡中,演示物品系统的完整使用流程
|
||||
- 在蓝图编辑器中配置:创建 UDefaultContainer 作为 `ItemContainer`,通过 CreateItem 创建炸弹物品并记录 `Item ID`
|
||||
- 创建 UItemTracer 实例并赋值给 `ItemLocation`,绑定 `OnItemMoved` 委托监听物品位置变化
|
||||
- `GetContainer()` 用于外部获取容器的物品操作接口
|
||||
- `FindActorInOuterChain()` 用于通过物品容器对象的 Outer 链查找实际持有该物品的 Actor
|
||||
- 当 `ItemLocation.OnItemMoved` 触发时(物品转移到其他容器),通过 `FindActorInOuterChain` 检测新持有者,并触发相应的业务逻辑(如爆炸)
|
||||
- 实现物品系统的完整交互演示:创建 -> 追踪 -> 转移检测 -> 响应
|
||||
|
||||
BP_Bomb 在项目中的典型调用流程:
|
||||
|
||||
- **炸弹初始化流程** — BeginPlay → GetContainer → CreateItem(TestBomb)→ GetItemProperty(获取 ItemTracer)→ 存入 ItemLocation 和 ItemID → 追踪器绑定委托
|
||||
- **物品移动触发流程** — 玩家拾取炸弹 → 炸弹被移出容器 → On Component Hit → 验证 ItemLocation → 获取目标 BP_InventoryComp → RequestMoveItem → 接口事件触发 → ReceiveItem 接收物品到新容器
|
||||
- **追踪器响应流程** — ItemLocation(UItemTracer)检测到物品移动 → 触发 OnItemMoved 委托 → 执行爆炸/响应逻辑
|
||||
|
||||
## 用例
|
||||
- 物品系统演示 Actor,展示 IItemContainer + UItemTracer 的完整交互流程
|
||||
- 放置于关卡中作为示例,演示物品创建、转移追踪、所有者检测等核心功能
|
||||
|
||||
| 引用方 | 路径 | 用途 |
|
||||
|--------|------|------|
|
||||
| Playground | `/Game/地图关卡/Playground` | 关卡中放置的交互示例,演示物品系统全流程 |
|
||||
|
||||
Reference in New Issue
Block a user