init
This commit is contained in:
46
Content/Blueprints/BP_Bomb.md
Normal file
46
Content/Blueprints/BP_Bomb.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# BP_Bomb
|
||||
|
||||
## 基本信息
|
||||
- **类型**: Blueprint (Actor)
|
||||
- **父类**: Actor
|
||||
- **源文件**: /Game/Blueprints/Playground/BP_Bomb.BP_Bomb
|
||||
- **模块**: Content
|
||||
|
||||
## 功能概述
|
||||
BP_Bomb 是物品系统和追踪器系统的交互核心示例 Actor。它结合了 IItemContainer(物品容器接口)、UItemTracer(物品追踪器)和 Owner 检测,演示了物品在 Actor 之间的完整生命周期:创建、追踪、转移和响应。
|
||||
|
||||
## 设计用意
|
||||
BP_Bomb 是最复杂的蓝图示例,演示了物品系统的全部核心功能。它通过 ItemContainer 持有炸弹物品的容器,通过 ItemLocation(UItemTracer)追踪炸弹物品的位置变化,通过 Item ID(GUID)实现跨容器追踪。追踪器绑定 OnItemMoved 委托,当检测到炸弹转移到其他容器时触发相应的业务逻辑(如爆炸)。GetContainer() 和 FindActorInOuterChain 函数则演示了 C++/蓝图桥接模式——在蓝图层面实现等同于 C++ UItemTracer 的查找逻辑。
|
||||
|
||||
## 职责范围
|
||||
BP_Bomb 负责演示物品+追踪器的完整交互流程,包括物品创建、容器查找、追踪器委托绑定、以及物品转移响应。底层容器存储实现由 UDefaultContainer 处理,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 个节点,处理物品生命周期演示逻辑
|
||||
|
||||
## 使用方法
|
||||
- 作为示例 Actor 放置到关卡中,演示物品系统的完整使用流程
|
||||
- 在蓝图编辑器中配置:创建 UDefaultContainer 作为 `ItemContainer`,通过 CreateItem 创建炸弹物品并记录 `Item ID`
|
||||
- 创建 UItemTracer 实例并赋值给 `ItemLocation`,绑定 `OnItemMoved` 委托监听物品位置变化
|
||||
- `GetContainer()` 用于外部获取容器的物品操作接口
|
||||
- `FindActorInOuterChain()` 用于通过物品容器对象的 Outer 链查找实际持有该物品的 Actor
|
||||
- 当 `ItemLocation.OnItemMoved` 触发时(物品转移到其他容器),通过 `FindActorInOuterChain` 检测新持有者,并触发相应的业务逻辑(如爆炸)
|
||||
- 实现物品系统的完整交互演示:创建 -> 追踪 -> 转移检测 -> 响应
|
||||
|
||||
## 用例
|
||||
- 物品系统演示 Actor,展示 IItemContainer + UItemTracer 的完整交互流程
|
||||
- 放置于关卡中作为示例,演示物品创建、转移追踪、所有者检测等核心功能
|
||||
52
Content/Blueprints/BP_CameraPawn.md
Normal file
52
Content/Blueprints/BP_CameraPawn.md
Normal file
@@ -0,0 +1,52 @@
|
||||
# BP_CameraPawn
|
||||
|
||||
## 基本信息
|
||||
- **类型**: Blueprint (Pawn)
|
||||
- **父类**: ACameraPawn
|
||||
- **源文件**: /Game/Blueprints/BP_CameraPawn.BP_CameraPawn
|
||||
- **模块**: Content
|
||||
|
||||
## 功能概述
|
||||
BP_CameraPawn 是分离式第三人称摄像机的蓝图实现,继承 C++ 的 ACameraPawn。在蓝图层面配置摄像机参数(初始旋转、臂长范围、速度等),并提供编辑器内可视化调整能力。
|
||||
|
||||
## 设计用意
|
||||
ACameraPawn 在 C++ 层提供了完整的 SpringArm+Camera 组件和缩放、旋转、移动、重置逻辑。BP_CameraPawn 作为蓝图配置层,将摄像机的默认参数(初始旋转 -60 度、初始臂长 1200、臂长范围 300-3000、旋转速度 2.0、缩放速度 10.0、移动速度 10.0、移动限制 800)暴露在蓝图中,方便在编辑器内调整和迭代。
|
||||
|
||||
## 职责范围
|
||||
BP_CameraPawn 负责摄像机参数的蓝图级配置和编辑器内可视化调整。底层的摄像机变换逻辑(SpringArm 的臂长插值、旋转计算、移动偏移等)全部由 ACameraPawn C++ 层处理。
|
||||
|
||||
## 项目内依赖
|
||||
| 依赖项 | 关系 | 源文件 |
|
||||
|--------|------|--------|
|
||||
| ACameraPawn | 父类 | C++ 源码 |
|
||||
|
||||
## 对外接口
|
||||
- **继承自 ACameraPawn 的 BlueprintCallable 函数**:
|
||||
- `CameraZoom(const FInputActionValue& Value)` -- 摄像机缩放,调整 SpringArm 臂长
|
||||
- `CameraRotate(const FInputActionValue& Value)` -- 摄像机旋转,调整 SpringArm 的旋转偏移
|
||||
- `CameraMove(const FInputActionValue& Value)` -- 摄像机平移,调整 SpringArm 的 SocketOffset
|
||||
- `CameraReset(const FInputActionValue& Value)` -- 重置摄像机到默认位置和旋转
|
||||
- **继承自 ACameraPawn 的 BlueprintReadOnly 属性**:
|
||||
- `SpringArmComponent` (USpringArmComponent*) -- SpringArm 组件引用
|
||||
- `CameraComponent` (UCameraComponent*) -- Camera 组件引用
|
||||
- `FollowTarget` (APawn*) -- 跟随目标 Pawn(VisibleInstanceOnly)
|
||||
- **蓝图可调的配置参数**(EditDefaultsOnly, BlueprintReadOnly):
|
||||
- `InitialRotation` = FRotator(-60, 0, 0) -- 初始俯仰角
|
||||
- `InitialArmLength` = 1200.0f -- 初始臂长
|
||||
- `RotateSpeed` = 2.0f -- 旋转速度
|
||||
- `ZoomSpeed` = 10.0f -- 缩放速度
|
||||
- `MoveSpeed` = 10.0f -- 平移速度
|
||||
- `MaxArmLength` = 3000.0f / `MinArmLength` = 300.0f -- 臂长范围
|
||||
- `CameraMoveClamp` = 800.0 -- 平移限制范围
|
||||
|
||||
## 使用方法
|
||||
- 通过 BP_TestChar (AMyCharacter) 的 `CameraActorClass` 属性配置,角色 Possess 时自动生成摄像机实例
|
||||
- 继承自 ACameraPawn,C++ 层提供了完整的 SpringArm+Camera 组件和变换逻辑
|
||||
- 蓝图层面可在 EventGraph 中响应事件(event_count=3,node_count=3)
|
||||
- 配置参数均为 `EditDefaultsOnly`,在蓝图类默认值中调整摄像机行为,无需修改 C++ 代码
|
||||
- ACameraPawn 的 Tick() 处理每帧的臂长插值、旋转跟随和移动偏移,蓝图不参与底层变换
|
||||
- `FollowTarget` 在运行时由 SetFollowTarget 逻辑自动设置为当前控制的角色
|
||||
|
||||
## 用例
|
||||
- BP_TestChar (AMyCharacter) 中 `CameraActorClass` 属性引用,作为角色的分离式摄像机
|
||||
- 被 Possess 角色时自动生成,跟随 `FollowTarget` Pawn
|
||||
55
Content/Blueprints/BP_ControllerComp.md
Normal file
55
Content/Blueprints/BP_ControllerComp.md
Normal file
@@ -0,0 +1,55 @@
|
||||
# BP_ControllerComp
|
||||
|
||||
## 基本信息
|
||||
- **类型**: Blueprint (ActorComponent)
|
||||
- **父类**: BP_EndpointComp_C (即 UEndpointComponent)
|
||||
- **源文件**: /Game/Blueprints/Component/BP_ControllerComp.BP_ControllerComp
|
||||
- **模块**: Content
|
||||
|
||||
## 功能概述
|
||||
BP_ControllerComp 是自定义控制器端点组件,管理摄像机的缩放和跟随模式。持有多个摄像机相关配置参数:移动速度(MoveSpeed)、臂长范围(MinArmLength / MaxArmLength)、缩放速度(ZoomSpeed)、跟随模式开关(IsFollowMode)以及跟随目标角色引用(FollowedChar)。
|
||||
|
||||
## 设计用意
|
||||
BP_ControllerComp 是 BP_TestChar 上最复杂的端点组件,负责处理摄像机控制指令。它持有自己的配置参数而非依赖 ACameraPawn 的默认值,表明它可能在运行时动态调整摄像机行为,例如切换跟随模式、调整臂长和移动速度。IsFollowMode 和 FollowedChar 的组合支持摄像机锁定特定角色的功能。
|
||||
|
||||
## 职责范围
|
||||
BP_ControllerComp 负责摄像机控制参数的管理、跟随模式的切换以及摄像机移动指令的处理。摄像机实际的 SpringArm 变换和空间计算由 ACameraPawn 及其 SpringArm 组件负责。
|
||||
|
||||
## 项目内依赖
|
||||
| 依赖项 | 关系 | 源文件 |
|
||||
|--------|------|--------|
|
||||
| BP_EndpointComp_C | 父类 | CharacterControl 插件 |
|
||||
| UEndpointComponent | 祖父类 | CharacterControl 插件 |
|
||||
| ACharacter | 引用 (FollowedChar) | 引擎内置 |
|
||||
|
||||
## 对外接口
|
||||
- **蓝图函数**:
|
||||
- `MoveController(A: GameplayTag, InVec: Vector)` -- 摄像机移动指令处理,接收 GameplayTag 和移动向量
|
||||
- `RotateController(A: GameplayTag, InVec: Vector)` -- 摄像机旋转指令处理
|
||||
- `ZoomCamera(A: GameplayTag, InVec: Vector)` -- 摄像机缩放指令处理,通过 InVec 中的值调整臂长
|
||||
- `ResetControllerLocation(DiscreteMeta: DiscreteMeta)` -- 摄像机位置重置,接收离散命令元数据
|
||||
- `TickFollowChar()` -- 跟随模式每帧更新,将摄像机位置锁定到 FollowedChar
|
||||
- **蓝图变量**(均为 is_instance_editable):
|
||||
- `MoveSpeed` (double) -- 摄像机移动速度
|
||||
- `MinArmLength` (double) -- 最小臂长
|
||||
- `MaxArmLength` (double) -- 最大臂长
|
||||
- `ZoomSpeed` (double) -- 缩放速度
|
||||
- `IsFollowMode` (bool) -- 是否启用跟随模式
|
||||
- `FollowedChar` (Character*) -- 跟随目标角色引用
|
||||
- **继承自 (BP_EndpointComp_C / UEndpointComponent) 的接口**:
|
||||
- `EndpointState` -- 端点状态,含 `InterestedTags` 配置摄像机控制相关标签
|
||||
- `OnCommandReceived` -- 收到指令时的处理入口
|
||||
- **EventGraph**:含 6 个事件和 27 个节点,处理摄像机控制的核心逻辑
|
||||
|
||||
## 使用方法
|
||||
- 作为 ActorComponent 添加到 BP_TestChar
|
||||
- 在组件实例上配置 `MoveSpeed`、`MinArmLength`、`MaxArmLength`、`ZoomSpeed` 等摄像机参数
|
||||
- 通过 `EndpointState.InterestedTags` 配置关注的摄像机控制 GameplayTag(如 "Camera.Move"、"Camera.Zoom"、"Camera.Rotate"、"Camera.Reset")
|
||||
- 开启 `IsFollowMode` 并设置 `FollowedChar` 可启用角色跟随模式
|
||||
- `MoveController`、`RotateController`、`ZoomCamera` 函数由 OnCommandReceived 事件根据指令标签分发调用
|
||||
- `TickFollowChar()` 在 EventGraph 的 Tick 事件中调用,实现每帧跟随
|
||||
- `UCommandRouterComponent` 自动发现并注册本组件
|
||||
|
||||
## 用例
|
||||
- BP_TestChar 的组件,处理摄像机控制指令
|
||||
- 通过配置参数在运行时动态调整 ACameraPawn 的行为(臂长、速度、跟随目标)
|
||||
45
Content/Blueprints/BP_DefaultContainer.md
Normal file
45
Content/Blueprints/BP_DefaultContainer.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# BP_DefaultContainer
|
||||
|
||||
## 基本信息
|
||||
- **类型**: Blueprint (UObject)
|
||||
- **父类**: UDefaultContainer
|
||||
- **源文件**: /Game/Blueprints/Playground/BP_DefaultContainer.BP_DefaultContainer
|
||||
- **模块**: Content
|
||||
|
||||
## 功能概述
|
||||
BP_DefaultContainer 是 UDefaultContainer 的蓝图子类,作为物品系统的默认容器在蓝图层中使用。无额外自定义变量,直接使用 C++ 父类的完整 IItemContainer 实现,提供 CreateItem、GetItemViews、MoveItem 等物品操作接口。
|
||||
|
||||
## 设计用意
|
||||
UDefaultContainer 是 C++ 中 IItemContainer 的默认实现,但不方便在编辑器中直接引用。BP_DefaultContainer 提供了一个蓝图可引用、可放置的资产版本,使得其他蓝图(如 BP_InventoryComp)可以通过编辑器直接引用它作为物品存储容器,简化了工作流。
|
||||
|
||||
## 职责范围
|
||||
BP_DefaultContainer 作为物品容器的蓝图实例化版本,负责在编辑器中作为可引用的资产存在。底层的物品存储机制、IItemContainer 接口实现全部由 C++ 父类 UDefaultContainer 处理。
|
||||
|
||||
## 项目内依赖
|
||||
| 依赖项 | 关系 | 源文件 |
|
||||
|--------|------|--------|
|
||||
| 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++ 层实现
|
||||
|
||||
## 使用方法
|
||||
- 作为 UObject 资产创建并保存在 /Game/Blueprints/Playground/ 路径下
|
||||
- 被 BP_InventoryComp 的 `DefaultContainer` 变量引用,作为物品的实际存储容器
|
||||
- 通过 IItemContainer 接口的所有 BlueprintCallable 函数进行物品操作
|
||||
- 实际存储逻辑由 C++ 父类 UDefaultContainer 的 `TArray<TUniquePtr<FItemInstance>> Items` 处理
|
||||
- BP_DefaultContainer 存在的意义是提供一个蓝图可引用的资产版本,方便在编辑器中直接拖拽配置
|
||||
- 无需在蓝图层面编写任何逻辑(functions=[]),完全依赖父类实现
|
||||
|
||||
## 用例
|
||||
- BP_InventoryComp 的 `DefaultContainer` 变量默认值,作为库存组件的底层存储
|
||||
- 任何需要 IItemContainer 接口的地方均可引用此资产
|
||||
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 引用以显示物品列表
|
||||
47
Content/Blueprints/BP_Hud.md
Normal file
47
Content/Blueprints/BP_Hud.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# BP_Hud
|
||||
|
||||
## 基本信息
|
||||
- **类型**: Blueprint (HUD)
|
||||
- **父类**: HUD
|
||||
- **源文件**: /Game/Blueprints/BP_Hud.BP_Hud
|
||||
- **模块**: Content
|
||||
|
||||
## 功能概述
|
||||
BP_Hud 是项目的 HUD 蓝图,管理三个 UI 窗口的引用:物品栏窗口(InvView,类型 WBP_InventoryView)、库存窗口(InventoryWindow)和提示窗口(HintWindow)。作为 UI 系统的"根"容器,持有并显示各种 Widget。
|
||||
|
||||
## 设计用意
|
||||
BP_Hud 将 UI 管理集中在 HUD 中,而不是分散在各个 Widget 或 Controller 中。它将物品视图、库存窗口和提示窗口都集中持有在一个地方,作为 UI 系统的入口点,方便其他系统通过 HUD 访问和操作 UI。
|
||||
|
||||
## 职责范围
|
||||
BP_Hud 负责持有主要 UI 窗口引用并作为 UI 系统的入口点。具体的 UI 逻辑(物品列表渲染、窗口交互、提示显示)由各 Widget 自身负责,BP_Hud 仅提供引用的集中管理。
|
||||
|
||||
## 项目内依赖
|
||||
| 依赖项 | 关系 | 源文件 |
|
||||
|--------|------|--------|
|
||||
| WBP_InventoryView | 引用 (InvView) | /Game/Blueprints/UI/Item/WBP_InventoryView |
|
||||
| WBP_Window | 引用 (InventoryWindow, HintWindow) | /Game/Blueprints/UI/WBP_Window |
|
||||
|
||||
## 对外接口
|
||||
- **蓝图可编辑变量**(均为 Instance Editable):
|
||||
- `InvView` (WBP_InventoryView_C*) -- 物品栏视图 Widget 引用,类型为 WBP_InventoryView
|
||||
- `InventoryWindow` (WBP_Window_C*) -- 库存窗口 Widget 引用,类型为 WBP_Window
|
||||
- `HintWindow` (WBP_Window_C*) -- 提示窗口 Widget 引用,类型为 WBP_Window
|
||||
- **继承自 AHUD 的标准接口**:
|
||||
- `DrawHUD()` -- HUD 绘制入口
|
||||
- `ReceiveDrawHUD(SizeX, SizeY)` -- 蓝图可覆盖的 UI 绘制事件
|
||||
- `GetOwningPlayerController()` -- 获取所属的 PlayerController
|
||||
- HUD 生命周期事件(BeginPlay、EndPlay 等)
|
||||
- **EventGraph**:含 4 个事件和 39 个节点,负责 Widget 的创建和初始化逻辑
|
||||
|
||||
## 使用方法
|
||||
- 在 BP_TestMode 中设置为 `HUDClass`,每次 PlayerController 初始化时自动创建
|
||||
- 在蓝图 EventGraph 中创建和初始化三个 Widget:`InvView`(物品栏)、`InventoryWindow`(库存窗口)、`HintWindow`(提示窗口)
|
||||
- 三个 Widget 变量为 Instance Editable,可在编辑器中替换为不同的 Widget 子类
|
||||
- 其他系统通过 `PlayerController->GetHUD()` 获取 BP_Hud 实例,再通过变量访问各 Widget
|
||||
- 作为 UI 系统的"根"容器,所有主要 UI 窗口的引用集中在此处管理
|
||||
|
||||
## 用例
|
||||
- BP_TestMode 的 `HUDClass`,玩家进入关卡时生成
|
||||
- `InvView` 变量引用 WBP_InventoryView,物品系统通过此引用更新物品列表 UI
|
||||
- `InventoryWindow` 变量引用 WBP_Window,库存窗口的显示和隐藏通过此引用控制
|
||||
- `HintWindow` 变量引用 WBP_Window,提示信息的显示通过此引用控制
|
||||
54
Content/Blueprints/BP_InventoryComp.md
Normal file
54
Content/Blueprints/BP_InventoryComp.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# BP_InventoryComp
|
||||
|
||||
## 基本信息
|
||||
- **类型**: Blueprint (ActorComponent)
|
||||
- **父类**: ActorComponent
|
||||
- **源文件**: /Game/Blueprints/Playground/BP_InventoryComp.BP_InventoryComp
|
||||
- **模块**: Content
|
||||
|
||||
## 功能概述
|
||||
BP_InventoryComp 是库存管理组件,包装了一个 UDefaultContainer 实例,持有物品视图缓存和视图变化委托,提供物品创建和视图更新功能。它是物品系统与 Actor 之间的桥梁组件,也是 IInventory 接口的蓝图实现者。
|
||||
|
||||
## 设计用意
|
||||
BP_InventoryComp 将库存功能封装为可复用的 ActorComponent,使任何 Actor 都可以通过添加此组件来获得库存能力。它通过 DefaultContainer 引用底层存储,通过 ViewCache 缓存物品视图避免重复生成,通过 OnViewChanged 委托通知 UI 更新。这种设计将库存管理从具体的 Actor 类型中解耦出来,提高了可复用性。
|
||||
|
||||
## 职责范围
|
||||
BP_InventoryComp 负责持有并管理 UDefaultContainer 实例、维护 FItemView 缓存、处理物品创建和视图更新、以及实现 IInventory 接口的蓝图逻辑。底层物品存储机制由 UDefaultContainer 处理,物品类型定义由 DataTable 负责。
|
||||
|
||||
## 项目内依赖
|
||||
| 依赖项 | 关系 | 源文件 |
|
||||
|--------|------|--------|
|
||||
| UDefaultContainer | 持有 (DefaultContainer) | Item 插件 |
|
||||
| BP_DefaultContainer | 默认实例 | /Game/Blueprints/Playground/BP_DefaultContainer |
|
||||
| FItemView | 缓存 (ViewCache) | Item 插件 |
|
||||
| IInventory | 实现 | Item 插件 |
|
||||
|
||||
## 对外接口
|
||||
- **蓝图函数**:
|
||||
- `UpdateViewCache()` -- 刷新 ViewCache,从 DefaultContainer 重新获取物品视图列表,同步缓存与底层容器状态
|
||||
- `CreateItemInternal(FName ItemType, int32 Count) -> bool` -- 内部物品创建函数,通过 DefaultContainer.CreateItem 创建物品后更新 ViewCache
|
||||
- **蓝图变量**(均为 is_instance_editable):
|
||||
- `DefaultContainer` (DefaultContainer*/UDefaultContainer*) -- 底层物品容器引用,默认指向 BP_DefaultContainer
|
||||
- `ViewCache` (TArray<FItemView>) -- 物品视图缓存数组,UI 从此读取显示数据,结构与 FItemView 一致(ItemID, ItemType, ItemName, ItemDescription, Icon, ItemDataText)
|
||||
- `OnViewChanged` (动态多播委托) -- 视图变化通知委托,每次 ViewCache 更新时广播,供 UI 绑定自动刷新
|
||||
- **IInventory 接口实现**(BlueprintNativeEvent):
|
||||
- `GetItemViews() -> TArray<FItemView>` -- 返回所有物品视图
|
||||
- `GetItemViewByID(const FGuid& ItemID) -> FItemView` -- 按 ID 获取视图
|
||||
- `GetItemCount() -> int32` -- 物品数量
|
||||
- `RequestMoveItem(const FGuid& ItemID, const TScriptInterface<IInventory>& TargetInventory)` -- 请求移动物品到目标库存
|
||||
- `ReceiveItem(const FGuid& ItemID, const TScriptInterface<IItemContainer>& SourceContainer)` (BlueprintAuthorityOnly) -- 从源容器接收物品
|
||||
- **EventGraph**:含 7 个事件和 30 个节点,处理库存初始化和生命周期
|
||||
|
||||
## 使用方法
|
||||
- 作为 ActorComponent 添加到需要库存功能的 Actor 上
|
||||
- 设置 `DefaultContainer` 变量指向 BP_DefaultContainer 资产(或其他 IItemContainer 实现)
|
||||
- UI (如 WBP_InventoryView) 绑定 `OnViewChanged` 委托,在库存变化时自动刷新
|
||||
- 调用 `CreateItemInternal(ItemType, Count)` 创建新物品,之后 ViewCache 自动更新
|
||||
- 通过 IInventory 接口与其他库存组件交互:`RequestMoveItem` 将物品移出,`ReceiveItem` 从其他容器接收物品
|
||||
- `UpdateViewCache` 在物品变化后同步缓存与底层容器的状态
|
||||
- 继承类 BP_DropItemInvComp 通过覆盖 BeginPlay 自动调用 CreateItemInternal
|
||||
|
||||
## 用例
|
||||
- BP_DropItemInvComp 的父类,提供库存管理的通用基础
|
||||
- WBP_InventoryView 通过 `Comp` 变量引用此组件,读取 ViewCache 渲染物品列表
|
||||
- 添加到任何 Actor 上使其具备库存能力
|
||||
45
Content/Blueprints/BP_MoveInput.md
Normal file
45
Content/Blueprints/BP_MoveInput.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# BP_MoveInput
|
||||
|
||||
## 基本信息
|
||||
- **类型**: Blueprint (ActorComponent)
|
||||
- **父类**: UEndpointComponent
|
||||
- **源文件**: /Game/Blueprints/Component/BP_MoveInput.BP_MoveInput
|
||||
- **模块**: Content
|
||||
|
||||
## 功能概述
|
||||
BP_MoveInput 是移动输入端点组件,持有对 CharacterMovementComponent 的引用(通过 CharMove 变量),将指令系统中的移动指令转化为实际的角色移动。
|
||||
|
||||
## 设计用意
|
||||
BP_MoveInput 是指令系统和 UE 移动系统之间的桥梁。它持有 `CharMove` (CharacterMovementComponent*) 引用,在 OnCommandReceived 中接收移动指令(连续指令,如 "Command.Move"),从 FCommandPacket.ContinuousPayload.ContinuousValue 提取移动向量,然后调用 CharacterMovementComponent 的移动接口。这种设计将输入系统和移动系统解耦——指令的生成、路由和执行分别由不同的组件负责。
|
||||
|
||||
## 职责范围
|
||||
BP_MoveInput 负责接收移动指令并将其转换为 CharacterMovementComponent 的移动调用。移动向量通过连续指令的 ContinuousValue 传入,由 BP_MoveInput 提取并应用。指令的生成由 UCommandInputComponent 负责,指令的路由匹配由 UCommandRouter 负责。
|
||||
|
||||
## 项目内依赖
|
||||
| 依赖项 | 关系 | 源文件 |
|
||||
|--------|------|--------|
|
||||
| UEndpointComponent | 父类 | CharacterControl 插件 |
|
||||
| UCharacterMovementComponent | 引用 (CharMove) | 引擎内置 |
|
||||
|
||||
## 对外接口
|
||||
- **蓝图变量**:
|
||||
- `CharMove` (CharacterMovementComponent*) -- 持有对所属角色的 CharacterMovementComponent 引用,is_instance_editable,可在组件实例上配置
|
||||
- **继承自 UEndpointComponent 的接口**:
|
||||
- `EndpointState` (FEndpointState) -- 端点状态,含 `InterestedTags` 配置关注的移动指令标签(如 "Command.Move")
|
||||
- `OnCommandReceived(const FCommandPacket& Command)` (BlueprintImplementableEvent) -- 收到移动指令时调用,在 EventGraph 中实现(node_count=22)
|
||||
- `OnEndpointStateChanged` / `OnCommandOutput` -- 状态和输出委托
|
||||
- **通过 EventGraph 的行为**:
|
||||
- 从 `Command.ContinuousPayload.ContinuousValue` 提取移动向量 (FVector3f)
|
||||
- 调用 `CharMove` 的移动接口将向量转化为实际角色移动
|
||||
|
||||
## 使用方法
|
||||
- 作为 ActorComponent 添加到 BP_TestChar
|
||||
- 设置 `CharMove` 变量指向所属角色的 `CharacterMovementComponent`
|
||||
- 配置 `EndpointState.InterestedTags` 添加移动相关 GameplayTag(如 "Command.Move")
|
||||
- 设置 `EndpointState.bIsContinuousFriendly = true`(移动是连续指令)
|
||||
- `UCommandRouterComponent` 自动发现并注册本组件为端点
|
||||
- 当 EnhancedInput 产生移动输入 -> UCommandInputComponent 生成 FCommandPacket -> UCommandRouterComponent 按标签匹配 -> 本组件的 OnCommandReceived 收到指令 -> 从 ContinuousPayload.ContinuousValue 提取 FVector3f -> 调用 CharacterMovementComponent 执行移动
|
||||
|
||||
## 用例
|
||||
- BP_TestChar 的组件,处理移动指令
|
||||
- 通过 `CharMove` 变量连接 CharacterMovementComponent,实现指令到移动的桥接
|
||||
43
Content/Blueprints/BP_SayHello.md
Normal file
43
Content/Blueprints/BP_SayHello.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# BP_SayHello
|
||||
|
||||
## 基本信息
|
||||
- **类型**: Blueprint (ActorComponent)
|
||||
- **父类**: UEndpointComponent
|
||||
- **源文件**: /Game/Blueprints/Component/BP_SayHello.BP_SayHello
|
||||
- **模块**: Content
|
||||
|
||||
## 功能概述
|
||||
BP_SayHello 是一个简单的测试/调试端点组件,用于验证 CharacterControl 指令路由系统是否正常工作。它没有任何自定义变量,仅覆盖 OnCommandReceived 事件输出 Hello 日志或消息。
|
||||
|
||||
## 设计用意
|
||||
作为 CharacterControl 插件的最小化端点实现示例,BP_SayHello 验证了从 EnhancedInput 到端点响应的全链路:EnhancedInput 产生输入动作,UCommandInputComponent 生成 FCommandPacket,UCommandRouter 进行标签匹配路由,最终到达 BP_SayHello 的 OnCommandReceived 并执行响应。它同时也可作为新端点的参考实现模板。
|
||||
|
||||
## 职责范围
|
||||
BP_SayHello 负责验证指令路由系统的端到端工作流程,并作为新端点的参考实现。它的处理逻辑极简(输出日志),不涉及任何业务逻辑。
|
||||
|
||||
## 项目内依赖
|
||||
| 依赖项 | 关系 | 源文件 |
|
||||
|--------|------|--------|
|
||||
| UEndpointComponent | 父类 | CharacterControl 插件 |
|
||||
|
||||
## 对外接口
|
||||
- **继承自 UEndpointComponent 的接口**:
|
||||
- `EndpointState` (FEndpointState) -- 端点状态,含 `InterestedTags` 配置关注的指令标签
|
||||
- `OnCommandReceived(const FCommandPacket& Command)` (BlueprintImplementableEvent) -- 收到匹配指令时调用,在 EventGraph 中实现(4 个事件、27 个节点)
|
||||
- `OnEndpointStateChanged` -- 状态变化委托
|
||||
- `OnCommandOutput` -- 命令输出委托
|
||||
- **无自定义蓝图变量**:纯行为型组件,不暴露状态数据
|
||||
|
||||
## 使用方法
|
||||
- 作为 ActorComponent 添加到 BP_TestChar,用作测试端点
|
||||
- 配置 `EndpointState.InterestedTags` 添加测试用 GameplayTag(如 "Command.SayHello")
|
||||
- `OnCommandReceived` 事件在蓝图 EventGraph 中实现:收到指令后输出调试日志或 Hello 消息
|
||||
- 配合 EnhancedInput 的测试输入动作使用:
|
||||
1. EnhancedInput 产生输入 -> UCommandInputComponent 生成 FCommandPacket
|
||||
2. UCommandRouterComponent 按标签匹配路由到本组件
|
||||
3. OnCommandReceived 触发,输出日志
|
||||
- 可作为新端点的实现模板:仅需在蓝图 EventGraph 中覆盖 `OnCommandReceived` 实现自定义行为
|
||||
|
||||
## 用例
|
||||
- BP_TestChar 的组件,验证 CharacterControl 指令路由系统的端到端工作流程
|
||||
- 当 EnhancedInput 绑定到 "Command.SayHello" 指令时,输出响应消息
|
||||
57
Content/Blueprints/BP_TestChar.md
Normal file
57
Content/Blueprints/BP_TestChar.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# BP_TestChar
|
||||
|
||||
## 基本信息
|
||||
- **类型**: Blueprint (Actor)
|
||||
- **父类**: AMyCharacter
|
||||
- **源文件**: /Game/Blueprints/BP_TestChar.BP_TestChar
|
||||
- **模块**: Content
|
||||
|
||||
## 功能概述
|
||||
BP_TestChar 是玩家主角的蓝图实现,继承 C++ 的 AMyCharacter。它通过添加 CharacterControl 插件的路由组件来扩展角色能力,在蓝图层面组合移动、指令路由和摄像机控制。
|
||||
|
||||
## 设计用意
|
||||
AMyCharacter 在 C++ 层提供了移动和摄像机 Pawn 创建的基础能力。BP_TestChar 在蓝图层面通过组件化的方式组装角色功能:添加 UCommandRouterComponent 将角色变成指令路由中心,添加各种 ICommandEndpoint 组件处理不同类型的指令。作为项目的核心 Pawn,它是指令系统和角色能力的"组装层"——新功能通过添加新的端点组件来扩展,而非修改 C++ 代码。
|
||||
|
||||
## 职责范围
|
||||
BP_TestChar 是角色的蓝图配置层,负责添加并配置 CharacterControl 路由组件和端点组件,实现角色重叠、Tick 等蓝图级逻辑。移动逻辑由 AMyCharacter C++ 层处理,摄像机逻辑由 ACameraPawn 负责。
|
||||
|
||||
## 项目内依赖
|
||||
| 依赖项 | 关系 | 源文件 |
|
||||
|--------|------|--------|
|
||||
| AMyCharacter | 父类 | /Game/Blueprints/BP_TestChar (C++ 继承) |
|
||||
| ACameraPawn | 间接(CameraActorClass) | /Game/Blueprints/BP_CameraPawn |
|
||||
| UCommandRouterComponent | 组件 | CharacterControl 插件 |
|
||||
| BP_UniversalEndpointComp | 组件 | /Game/Blueprints/Component/BP_UniversalEndpointComp |
|
||||
| BP_MoveInput | 组件 | /Game/Blueprints/Component/BP_MoveInput |
|
||||
| BP_ControllerComp | 组件 | /Game/Blueprints/Component/BP_ControllerComp |
|
||||
| BP_SayHello | 组件 | /Game/Blueprints/Component/BP_SayHello |
|
||||
|
||||
## 对外接口
|
||||
- **继承自 AMyCharacter 的 BlueprintCallable 函数**:
|
||||
- `Move(const FInputActionValue& Value)` -- 移动输入处理,供 EnhancedInput 绑定调用
|
||||
- `BeginRun(const FInputActionValue& Value)` / `StopRun(const FInputActionValue& Value)` -- 奔跑切换
|
||||
- `BeginCrouch(const FInputActionValue& Value)` / `StopCrouch(const FInputActionValue& Value)` -- 蹲伏切换
|
||||
- `IsRunning() const` / `IsCrouching() const` -- 状态查询
|
||||
- **继承自 AMyCharacter 的 BlueprintReadOnly 属性**:
|
||||
- `DefaultMapping` (UInputMappingContext*) -- 默认输入映射上下文
|
||||
- `MoveAction`, `RunAction`, `CrouchAction`, `CameraMoveAction`, `CameraZoomAction`, `CameraResetAction`, `CameraRotateAction` -- 各输入动作引用
|
||||
- `CameraActorClass` (TSubclassOf<ACameraPawn>) -- 摄像机 Pawn 类,设置为 BP_CameraPawn
|
||||
- **身上的组件作为对外能力**:
|
||||
- `UCommandRouterComponent` -- 指令路由中心,通过 RegisterEndpoint / InputCommand 接收和分发指令
|
||||
- `BP_UniversalEndpointComp` -- 通用端点,对外暴露 `CommandReceivedDispatcher` 动态多播委托
|
||||
- `BP_MoveInput` -- 移动端点,对外暴露 `CharMove` (CharacterMovementComponent*) 变量
|
||||
- `BP_ControllerComp` -- 摄像机控制端点,对外暴露 `MoveController`、`RotateController`、`ZoomCamera`、`ResetControllerLocation`、`TickFollowChar` 函数及摄像机配置参数
|
||||
- `BP_SayHello` -- 测试端点,验证指令路由系统
|
||||
|
||||
## 使用方法
|
||||
- 在 BP_TestMode 中设置为 `DefaultPawnClass`,作为项目的默认 Pawn
|
||||
- 在蓝图编辑器中添加 CharacterControl 路由和端点组件:`UCommandRouterComponent` 作为指令路由器,`BP_UniversalEndpointComp`、`BP_MoveInput`、`BP_ControllerComp`、`BP_SayHello` 作为各类指令端点
|
||||
- 通过父类 AMyCharacter 的 `CameraActorClass` 属性指定 BP_CameraPawn 作为分离式摄像机
|
||||
- 配置父类的 InputAction 属性(MoveAction、RunAction 等)连接 EnhancedInput 系统
|
||||
- 各端点组件通过 `EndpointState.InterestedTags` 配置关注的 GameplayTag,UCommandRouterComponent 的 `AutoRegisterEndpoints` 在 BeginPlay 时自动注册所有组件上的端点
|
||||
- 指令链路:EnhancedInput -> UCommandInputComponent -> UCommandRouterComponent -> 匹配的端点组件
|
||||
|
||||
## 用例
|
||||
- BP_TestMode 的 `DefaultPawnClass`,作为玩家进入关卡时的默认角色
|
||||
- 身上挂载的 `BP_UniversalEndpointComp`、`BP_MoveInput`、`BP_ControllerComp`、`BP_SayHello` 作为该角色的指令处理端点
|
||||
- `CameraActorClass` 属性引用 BP_CameraPawn,角色被 Possess 时自动生成摄像机
|
||||
43
Content/Blueprints/BP_TestCtl.md
Normal file
43
Content/Blueprints/BP_TestCtl.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# BP_TestCtl
|
||||
|
||||
## 基本信息
|
||||
- **类型**: Blueprint (PlayerController)
|
||||
- **父类**: AMyPlayerController
|
||||
- **源文件**: /Game/Blueprints/BP_TestCtl.BP_TestCtl
|
||||
- **模块**: Content
|
||||
|
||||
## 功能概述
|
||||
BP_TestCtl 是项目的玩家控制器蓝图实现,继承 C++ 的 AMyPlayerController。它实现了 OnClientPossessFinished 事件用于 Possess 完成后的初始化,并提供 SetupControllingPawn 自定义函数用于控制权切换后的 Pawn 设置。
|
||||
|
||||
## 设计用意
|
||||
BP_TestCtl 利用 AMyPlayerController 的禁用摄像机计算特性(支持 ACameraPawn 分离式摄像机),在蓝图层面提供 Possess 完成后的客户端初始化和 Pawn 设置逻辑。作为一个薄蓝图层,它将 C++ 层的控制器能力暴露给蓝图系统进行配置和扩展。
|
||||
|
||||
## 职责范围
|
||||
BP_TestCtl 负责 Possess 完成时的客户端初始化和控制权切换后的 Pawn 设置。摄像机计算由 C++ 层禁用(CalcCamera 空操作),角色移动由 AMyCharacter 负责,BP_TestCtl 不涉及这些底层逻辑。
|
||||
|
||||
## 项目内依赖
|
||||
| 依赖项 | 关系 | 源文件 |
|
||||
|--------|------|--------|
|
||||
| AMyPlayerController | 父类 | C++ 源码 |
|
||||
|
||||
## 对外接口
|
||||
- **继承自 AMyPlayerController 的 BlueprintCallable 函数**:
|
||||
- `GetOwnedPawn()` -- 获取当前控制的 Pawn,返回 APawn*,供蓝图查询当前 Possess 目标
|
||||
- **继承自 AMyPlayerController 的 BlueprintImplementableEvent 事件**:
|
||||
- `OnClientPossessFinished(APawn* P)` -- 客户端 Possess 完成时调用,在 BP_TestCtl 的 EventGraph 中实现,客户端收到 Possess 确认后的初始化入口(EventGraph 中 event_count=3)
|
||||
- **蓝图自定义函数**:
|
||||
- `SetupControllingPawn()` -- 控制权切换后的 Pawn 设置函数,无参数,在 EventGraph 的 18 个节点中被调用
|
||||
- **继承自 APlayerController 的标准接口**:所有 APlayerController 的标准事件和函数均可用(如 OnPossess、OnUnPossess、GetPlayerViewPoint 等)
|
||||
|
||||
## 使用方法
|
||||
- 在 BP_TestMode 中设置为 `PlayerControllerClass`,作为项目的默认玩家控制器
|
||||
- 父类 AMyPlayerController 重写了 `CalcCamera`(空操作),禁用默认摄像机计算,配合 ACameraPawn 的分离式摄像机设计
|
||||
- 父类 AMyPlayerController 重写了 `AcknowledgePossession`,在 Possess 确认后触发 `OnClientPossessFinished` 事件
|
||||
- `OnClientPossessFinished` 在蓝图 EventGraph 中实现,用于客户端在 Possess 完成后的初始化逻辑
|
||||
- `SetupControllingPawn` 在控制权切换时调用,设置新的受控 Pawn 所需的配置(如 UI 绑定、输入上下文切换等)
|
||||
- 作为薄蓝图层,主要职责是将 C++ 层的控制器能力暴露给蓝图系统
|
||||
|
||||
## 用例
|
||||
- BP_TestMode 的 `PlayerControllerClass`,每次玩家加入时实例化
|
||||
- `OnClientPossessFinished` 事件连接客户端 Possess 完成的初始化流程
|
||||
- `SetupControllingPawn` 在角色切换时重新配置 Pawn 资源
|
||||
47
Content/Blueprints/BP_TestMode.md
Normal file
47
Content/Blueprints/BP_TestMode.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# BP_TestMode
|
||||
|
||||
## 基本信息
|
||||
- **类型**: Blueprint (GameMode)
|
||||
- **父类**: GameModeBase
|
||||
- **源文件**: /Game/Blueprints/BP_TestMode.BP_TestMode
|
||||
- **模块**: Content
|
||||
|
||||
## 功能概述
|
||||
BP_TestMode 是项目的 GameMode 蓝图,配置默认的 Pawn、PlayerController 和 HUD 类,将项目的所有核心类串联起来。
|
||||
|
||||
## 设计用意
|
||||
作为项目唯一的 GameMode,BP_TestMode 将分散的蓝图类通过引擎框架连接在一起。它将 BP_TestChar 设为默认 Pawn、BP_TestCtl 设为玩家控制器、BP_Hud 设为 HUD 类,形成一个完整的游戏运行时配置。这样所有核心类型的替换只需要修改这一个地方。
|
||||
|
||||
## 职责范围
|
||||
BP_TestMode 负责配置默认游戏类和串联项目核心类型之间的关系。具体的角色行为、控制器逻辑、UI 管理分别由各自对应的类负责。
|
||||
|
||||
## 项目内依赖
|
||||
| 依赖项 | 关系 | 源文件 |
|
||||
|--------|------|--------|
|
||||
| BP_TestChar | DefaultPawn | /Game/Blueprints/BP_TestChar |
|
||||
| BP_TestCtl | PlayerController | /Game/Blueprints/BP_TestCtl |
|
||||
| BP_Hud | HUD | /Game/Blueprints/BP_Hud |
|
||||
|
||||
## 对外接口
|
||||
- **继承自 AGameModeBase 的标准接口**:
|
||||
- GameMode 生命周期事件:`InitGame`、`PreLogin`、`PostLogin`、`Logout`、`RestartPlayer`、`SpawnDefaultPawnAtTransform` 等,均可在蓝图 EventGraph 中覆盖(EventGraph 中 event_count=2, node_count=2)
|
||||
- `GetDefaultPawnClassForController` -- 返回配置的 DefaultPawnClass
|
||||
- GameMode 的标准函数和事件均继承可用
|
||||
- **编辑器配置属性**(通过 GameMode 基类继承):
|
||||
- `DefaultPawnClass` = BP_TestChar -- 默认 Pawn 类型
|
||||
- `PlayerControllerClass` = BP_TestCtl -- 玩家控制器类型
|
||||
- `HUDClass` = BP_Hud -- HUD 类型
|
||||
- 其他 GameMode 标准配置属性(GameStateClass、SpectatorClass 等)
|
||||
|
||||
## 使用方法
|
||||
- 在关卡的世界设置(World Settings)中将 `GameMode Override` 设置为 BP_TestMode
|
||||
- 或在项目设置中将其设为默认 GameMode,应用于所有关卡
|
||||
- 配置三个核心 class 属性,将 BP_TestChar、BP_TestCtl、BP_Hud 串联为一个完整游戏框架
|
||||
- EventGraph 中无额外蓝图逻辑(node_count=2),纯配置型蓝图,所有替换只需修改此文件中的属性值
|
||||
- 项目有且仅有一个 GameMode,所有核心类型的替换集中在此处管理
|
||||
|
||||
## 用例
|
||||
- 关卡 World Settings 的 `GameMode Override`,引擎启动时加载
|
||||
- `DefaultPawnClass=BP_TestChar` -- 新玩家进入时自动生成该 Pawn
|
||||
- `PlayerControllerClass=BP_TestCtl` -- 新玩家连接时自动创建该控制器
|
||||
- `HUDClass=BP_Hud` -- 创建控制器时自动生成该 HUD
|
||||
44
Content/Blueprints/BP_UniversalEndpointComp.md
Normal file
44
Content/Blueprints/BP_UniversalEndpointComp.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# BP_UniversalEndpointComp
|
||||
|
||||
## 基本信息
|
||||
- **类型**: Blueprint (ActorComponent)
|
||||
- **父类**: UEndpointComponent
|
||||
- **源文件**: /Game/Blueprints/Component/BP_UniversalEndpointComp.BP_UniversalEndpointComp
|
||||
- **模块**: Content
|
||||
|
||||
## 功能概述
|
||||
BP_UniversalEndpointComp 是通用指令端点组件,继承 CharacterControl 的 UEndpointComponent。它添加了 `CommandReceivedDispatcher` 事件分发器委托,让其他蓝图可以动态绑定到该端点的指令接收事件,无需创建新子类。
|
||||
|
||||
## 设计用意
|
||||
UEndpointComponent 提供了 OnCommandReceived (BlueprintImplementableEvent) 用于蓝图处理指令,但该事件只能在子类中覆盖,外部蓝图无法直接订阅。BP_UniversalEndpointComp 通过添加一个动态多播委托 `CommandReceivedDispatcher`,在收到指令时将事件转发为委托广播,使外部蓝图也能监听该端点的指令接收事件,提升了端点组件的可组合性。
|
||||
|
||||
## 职责范围
|
||||
BP_UniversalEndpointComp 负责提供外部的指令接收委托,将内部事件转发为可外部订阅的委托。它不处理具体的指令逻辑(由外部订阅者负责),也不涉及路由器逻辑(由 UCommandRouter 负责)。
|
||||
|
||||
## 项目内依赖
|
||||
| 依赖项 | 关系 | 源文件 |
|
||||
|--------|------|--------|
|
||||
| UEndpointComponent | 父类 | CharacterControl 插件 |
|
||||
|
||||
## 对外接口
|
||||
- **蓝图变量**:
|
||||
- `CommandReceivedDispatcher` (动态多播委托) -- 指令接收事件分发器,is_instance_editable,其他蓝图可绑定此委托接收指令通知
|
||||
- **继承自 UEndpointComponent 的接口**:
|
||||
- `EndpointState` (FEndpointState) -- 端点状态,含 `EndpointGuid`、`InterestedTags` (FGameplayTagContainer)、`bIsActive`、`bIsContinuousFriendly`、`bIsAsynchronous`
|
||||
- `OnCommandReceived(const FCommandPacket& Command)` (BlueprintImplementableEvent) -- 收到匹配指令时调用,可在蓝图子类或本蓝图 EventGraph 中实现
|
||||
- `OnEndpointStateChanged` (FOnEndpointStateChanged) -- 状态变化委托
|
||||
- `OnCommandOutput` (FOnCommandOutput) -- 命令输出委托
|
||||
- **继承自 ICommandEndpoint 接口**:
|
||||
- `ReceiveCommand_BP(const FCommandPacket& Command)` (BlueprintNativeEvent) -- 蓝图版本的指令接收入口
|
||||
- `GetEndpointDispatcher_BP()` (BlueprintNativeEvent) -- 获取端点分发器
|
||||
|
||||
## 使用方法
|
||||
- 作为 ActorComponent 添加到 BP_TestChar 等需要通用指令处理的 Actor 上
|
||||
- 配置 `EndpointState.InterestedTags` 指定该端点关注的 GameplayTag 集合
|
||||
- 外部蓝图通过绑定 `CommandReceivedDispatcher` 委托来监听指令,无需创建新的端点子类
|
||||
- EventGraph 中当 `OnCommandReceived` 触发时,自动广播 `CommandReceivedDispatcher`,将内部事件转发为外部委托
|
||||
- `UCommandRouterComponent` 在 BeginPlay 时通过 `AutoRegisterEndpoints` 自动发现并注册本组件
|
||||
|
||||
## 用例
|
||||
- BP_TestChar 的组件,作为通用指令端点接收路由来的指令
|
||||
- 外部蓝图通过绑定 `CommandReceivedDispatcher` 订阅指令事件
|
||||
49
Content/Blueprints/WBP_InventoryView.md
Normal file
49
Content/Blueprints/WBP_InventoryView.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# WBP_InventoryView
|
||||
|
||||
## 基本信息
|
||||
- **类型**: Widget Blueprint (UserWidget)
|
||||
- **父类**: UserWidget
|
||||
- **源文件**: /Game/Blueprints/UI/Item/WBP_InventoryView.WBP_InventoryView
|
||||
- **模块**: Content
|
||||
|
||||
## 功能概述
|
||||
WBP_InventoryView 是物品列表显示 Widget,持有 BP_InventoryComp 组件的引用,负责将库存中的物品视图列表渲染到 UI。通过 UpdateListItems 函数刷新列表显示,使用 WBP_ItemViewBox 作为单个物品视图框的子 Widget。
|
||||
|
||||
## 设计用意
|
||||
WBP_InventoryView 是物品系统和 UI 系统之间的桥梁。它通过 Comp 变量引用 BP_InventoryComp,从中读取 ViewCache 获取物品视图数据,然后渲染到 UI 列表。通过监听 Comp 的 OnViewChanged 委托,它能在库存变化时自动刷新显示,无需手动触发更新。这种设计将数据层(BP_InventoryComp)和显示层(WBP_InventoryView)完全解耦。
|
||||
|
||||
## 职责范围
|
||||
WBP_InventoryView 负责显示物品列表 UI、监听库存变化并自动刷新、以及提供物品交互的入口。物品数据管理由 BP_InventoryComp 负责,物品存储由 UDefaultContainer 负责。
|
||||
|
||||
## 项目内依赖
|
||||
| 依赖项 | 关系 | 源文件 |
|
||||
|--------|------|--------|
|
||||
| BP_InventoryComp | 引用 (Comp) | /Game/Blueprints/Playground/BP_InventoryComp |
|
||||
| FItemView | 显示数据 | Item 插件 |
|
||||
| WBP_ItemViewBox | 子 Widget | /Game/Blueprints/UI/Item/WBP_ItemViewBox |
|
||||
|
||||
## 对外接口
|
||||
- **蓝图函数**:
|
||||
- `UpdateListItems()` -- 刷新物品列表显示,从 `Comp` (BP_InventoryComp) 的 ViewCache 读取 FItemView 数据并更新 UI 列表
|
||||
- **蓝图变量**(均为 is_instance_editable):
|
||||
- `Bo` (bool) -- 布尔标志位,用于控制 UI 显示/隐藏或其他状态
|
||||
- `Comp` (BP_InventoryComp_C*) -- 目标库存组件引用,指向要显示的 BP_InventoryComp 实例。UI 从此组件的 ViewCache 读取物品数据
|
||||
- **通过 Comp 变量访问的 BP_InventoryComp 接口**:
|
||||
- `ViewCache` (TArray<FItemView>) -- 物品视图缓存,包含 ItemID、ItemType、ItemName、ItemDescription、Icon、ItemDataText
|
||||
- `OnViewChanged` (动态多播委托) -- 绑定此委托实现库存变化时自动调用 UpdateListItems
|
||||
- `CreateItemInternal` -- 可用于触发物品创建(通常不直接从此 Widget 调用)
|
||||
- **EventGraph**:含 5 个事件和 8 个节点
|
||||
|
||||
## 使用方法
|
||||
- 作为 UMG UserWidget,被 BP_Hud 的 `InvView` 变量引用(类型为 WBP_InventoryView_C*)
|
||||
- 设置 `Comp` 变量指向目标 Actor 上的 BP_InventoryComp 实例,建立 UI 到数据的绑定
|
||||
- 在 EventGraph 中绑定 `Comp.OnViewChanged` 委托,每次库存变化时自动调用 `UpdateListItems` 刷新列表
|
||||
- `UpdateListItems` 从 `Comp.ViewCache` 读取 FItemView 数组,遍历创建 WBP_ItemViewBox 子 Widget 填充列表
|
||||
- WBP_ItemViewBox 作为单个物品的视图框,显示物品图标、名称、描述等信息
|
||||
- `Bo` 布尔变量用于控制 ListView 的条件显示(如空库存时隐藏列表)
|
||||
- 物品系统的数据流向:UDefaultContainer (存储) -> BP_InventoryComp (管理+ViewCache) -> WBP_InventoryView (显示)
|
||||
|
||||
## 用例
|
||||
- BP_Hud 的 `InvView` 变量引用,作为物品栏 UI 界面
|
||||
- 通过 `Comp` 变量绑定 BP_InventoryComp,显示玩家或掉落物的物品列表
|
||||
- 使用 WBP_ItemViewBox 作为子 Widget 渲染单个物品视图
|
||||
57
Content/Blueprints/WBP_TestUI.md
Normal file
57
Content/Blueprints/WBP_TestUI.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# WBP_TestUI
|
||||
|
||||
## 基本信息
|
||||
- **类型**: Widget Blueprint (UserWidget)
|
||||
- **父类**: UserWidget
|
||||
- **源文件**: /Game/Blueprints/UI/Dialog/WBP_TestUI.WBP_TestUI
|
||||
- **模块**: Content
|
||||
|
||||
## 功能概述
|
||||
WBP_TestUI 是对话演示脚本的显示/执行 Widget,实现了 IPresentationScriptExecutor 接口。它接收 FDialogPresentationScriptData,解析其中的 JSON 命令,构建 UI 选择按钮,驱动演示脚本的执行流。同时持有 Ultra Dynamic Sky 引用以支持环境变化命令。
|
||||
|
||||
## 设计用意
|
||||
WBP_TestUI 是 Dialog 插件在 UI 层的具体实现,承担了脚本执行和 UI 展示的双重职责。在脚本执行侧,它通过 IPresentationScriptExecutor 接口接收 UDialogPresentationSubsystem 的脚本调用,使用 ExecuteScript 启动脚本、ProcessScript 逐条执行命令、ExecuteNextScript 控制流程跳转。在 UI 管理侧,它通过 SummonChoiceButtons 动态生成选项按钮、SetNextScript 设置跳转目标、Get_MainText_Text 绑定主文本显示。这种双职责设计使一个 Widget 即可完成从数据到显示的完整链路。
|
||||
|
||||
## 职责范围
|
||||
WBP_TestUI 负责演示脚本的接收和执行、对话 UI 的生成和更新、脚本流程控制(跳转、选项分支)。命令的具体实现由 IPresentationStrategyPlugin 处理,DataTable 管理由 UDialogPresentationSubsystem 负责。
|
||||
|
||||
## 项目内依赖
|
||||
| 依赖项 | 关系 | 源文件 |
|
||||
|--------|------|--------|
|
||||
| FDialogPresentationScriptData | 输入数据 | Dialog 插件 |
|
||||
| FDialogPresentationScriptCommand | 输入数据 | Dialog 插件 |
|
||||
| IPresentationScriptExecutor | 实现接口 | Dialog 插件 |
|
||||
| UDialogPresentationSubsystem | 调用 | Dialog 插件 |
|
||||
|
||||
## 对外接口
|
||||
- **蓝图函数**:
|
||||
- `ExecuteScript(FDialogPresentationScriptData InScript)` -- 启动演示脚本,接收脚本数据并开始执行流程
|
||||
- `ProcessScript(FDialogPresentationScriptCommand Presentation)` -- 处理单条脚本命令,逐条执行演示命令
|
||||
- `ExecuteNextScript(FName Name)` -- 跳转到指定名称的下一个脚本,实现脚本流程控制
|
||||
- `SummonChoiceButtons(FDialogPresentationScriptData Data)` -- 根据脚本数据中的 Choices 字段动态生成选择按钮 UI
|
||||
- `SetNextScritp(FDialogPresentationScriptData Data)` -- 设置下一个要执行的脚本(通过 NextScriptName 变量)
|
||||
- `Get_MainText_Text() -> FText` -- 数据绑定函数,返回主文本框的对话文本内容
|
||||
- **蓝图变量**(均为 is_instance_editable):
|
||||
- `NextScriptName` (FName) -- 存储下一个脚本的名称,用于流程跳转
|
||||
- `Sky` (Ultra_Dynamic_Sky_C*) -- Ultra Dynamic Sky 引用,用于执行环境变化命令(如改变天气、时间)
|
||||
- **IPresentationScriptExecutor 接口实现**(BlueprintNativeEvent):
|
||||
- `ExecutePresentationScript(const FDialogPresentationScriptData& ScriptStruct)` -- 执行演示脚本
|
||||
- `PlugStrategyIn(FName StrategyName, const TScriptInterface<IPresentationStrategyPlugin>& NewStrategy)` -- 插件式注入策略
|
||||
- `UnplugStrategy(FName StrategyName)` -- 移除策略插件
|
||||
- **EventGraph**:含 5 个事件和 8 个节点
|
||||
|
||||
## 使用方法
|
||||
- 作为 UserWidget 创建并添加到视口,通常由 UDialogPresentationSubsystem 管理
|
||||
- 实现 IPresentationScriptExecutor 接口,作为 Dialog 插件的脚本执行器
|
||||
- UDialogPresentationSubsystem 调用 `ExecutePresentationScript` 投递脚本,本 Widget 通过 `ExecuteScript` 启动执行
|
||||
- `ProcessScript` 逐条解析脚本命令:通过 UPresentationJsonLibrary 解析 JSON 命令字符串,识别 CommandName 和 Params
|
||||
- `SummonChoiceButtons` 根据 Choices 数据动态创建选项按钮列表,按钮绑定 `ExecuteNextScript` 处理选择
|
||||
- `SetNextScritp` / `ExecuteNextScript` 控制脚本流程的线性或分支推进
|
||||
- `Get_MainText_Text` 作为 UMG 数据绑定函数,连接 UI 文本框显示对话内容
|
||||
- `Sky` 变量用于连接到场景中的 Ultra Dynamic Sky Actor,脚本命令可改变天气/时间等环境效果
|
||||
- 策略插件通过 `PlugStrategyIn` / `UnplugStrategy` 动态注入,支持在运行时扩展脚本命令的处理策略
|
||||
|
||||
## 用例
|
||||
- Dialog 系统的 UI 执行器,实现 IPresentationScriptExecutor 接口
|
||||
- 由 UDialogPresentationSubsystem 调用,作为对话脚本的显示和交互界面
|
||||
- 通过 `Sky` 变量连接 Ultra Dynamic Sky,支持演示脚本中的环境效果命令
|
||||
44
Content/Blueprints/_relationships.md
Normal file
44
Content/Blueprints/_relationships.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# Content/Blueprints 依赖关系
|
||||
|
||||
## 文件间引用关系
|
||||
|
||||
| 源文件 | 引用方式 | 目标文件 | 目标单位 |
|
||||
|--------|---------|---------|---------|
|
||||
| BP_TestChar | 父类 | AMyCharacter | Source/lonese/MyCharacter.h |
|
||||
| BP_TestCtl | 父类 | AMyPlayerController | Source/lonese/MyPlayerController.h |
|
||||
| BP_CameraPawn | 父类 | ACameraPawn | Source/lonese/CameraPawn.h |
|
||||
| BP_TestMode | 父类 | GameModeBase | Engine |
|
||||
| BP_Hud | 父类 | HUD | Engine |
|
||||
| BP_UniversalEndpointComp | 父类 | UEndpointComponent | CharacterControl plugin |
|
||||
| BP_MoveInput | 父类 | UEndpointComponent | CharacterControl plugin |
|
||||
| BP_ControllerComp | 父类 | BP_EndpointComp_C | Content/Blueprints |
|
||||
| BP_SayHello | 父类 | UEndpointComponent | CharacterControl plugin |
|
||||
| BP_DefaultContainer | 父类 | UDefaultContainer | Item plugin |
|
||||
| BP_InventoryComp | 父类 | ActorComponent | Engine |
|
||||
| BP_DropItemInvComp | 父类 | BP_InventoryComp | Content/Blueprints |
|
||||
| BP_Bomb | 父类 | Actor | Engine |
|
||||
| WBP_TestUI | 父类 | UserWidget | Engine |
|
||||
| WBP_InventoryView | 父类 | UserWidget | Engine |
|
||||
| BP_TestChar | 组件 | BP_UniversalEndpointComp | Content/Blueprints |
|
||||
| BP_TestChar | 组件 | BP_MoveInput | Content/Blueprints |
|
||||
| BP_TestChar | 组件 | BP_ControllerComp | Content/Blueprints |
|
||||
| BP_TestChar | 组件 | BP_SayHello | Content/Blueprints |
|
||||
| BP_TestChar | 组件 | UCommandRouterComponent | CharacterControl plugin |
|
||||
| BP_TestChar | CameraActorClass | BP_CameraPawn | Content/Blueprints |
|
||||
| BP_TestMode | DefaultPawnClass | BP_TestChar | Content/Blueprints |
|
||||
| BP_TestMode | PlayerControllerClass | BP_TestCtl | Content/Blueprints |
|
||||
| BP_TestMode | HUDClass | BP_Hud | Content/Blueprints |
|
||||
|
||||
## 关键依赖链
|
||||
|
||||
Game Mode → Pawn: BP_TestMode (DefaultPawnClass=BP_TestChar, PlayerControllerClass=BP_TestCtl, HUDClass=BP_Hud)
|
||||
|
||||
Character → Camera: BP_TestChar → CameraActorClass=BP_CameraPawn → ACameraPawn
|
||||
|
||||
Input Pipeline: BP_TestCtl (AMyPlayerController) → Enhanced Input → UCommandInputComponent (on BP_TestChar) → UCommandRouterComponent → UEndpointComponent subclasses
|
||||
|
||||
Item Pipeline: BP_DefaultContainer (UDefaultContainer) ← BP_InventoryComp (IInventory) ← BP_DropItemInvComp
|
||||
|
||||
UI Pipeline: WBP_TestUI (implements IPresentationScriptExecutor) → UDialogPresentationSubsystem
|
||||
|
||||
Item UI: WBP_InventoryView → BP_InventoryComp (via ViewCache/OnViewChanged) → BP_DefaultContainer (IItemContainer)
|
||||
Reference in New Issue
Block a user