# BP_SayHello ## 基本信息 - **类型**: Blueprint (ActorComponent) - **父类**: UEndpointComponent - **源文件**: /Game/Blueprints/Component/BP_SayHello.BP_SayHello - **模块**: Content/Blueprints/Component ## 功能概述 BP_SayHello 是一个简单的测试/调试端点组件,用于验证 CharacterControl 指令路由系统是否正常工作。它没有任何自定义变量,仅覆盖 OnCommandReceived 事件输出 Hello 日志或消息。 ## 设计用意 作为 CharacterControl 插件的最小化端点实现示例,BP_SayHello 验证了从 EnhancedInput 到端点响应的全链路:EnhancedInput 产生输入动作,UCommandInputComponent 生成 FCommandPacket,UCommandRouter 进行标签匹配路由,最终到达 BP_SayHello 的 OnCommandReceived 并执行响应。它同时也可作为新端点的参考实现模板。 ## 职责范围 BP_SayHello 负责验证指令路由系统的端到端工作流程,并作为新端点的参考实现。它的处理逻辑极简(输出日志),不涉及任何业务逻辑。 ## 项目内依赖 | 依赖项 | 关系 | 源文件 | |--------|------|--------| | UEndpointComponent | 父类 | CharacterControl 插件 | ## 外部视角 BP_SayHello 是 UEndpointComponent 的蓝图子类,从外部调用者视角: **接口概览** - 无自定义变量或公开函数 - 继承 UEndpointComponent 的 OnCommandReceived(BlueprintImplementableEvent),收到指令时输出日志 - 纯测试/演示用途,不暴露可供外部调用的 API **EventGraph 事件** | 事件 | 类型 | 触发时机 | 行为 | |------|------|----------|------| | `事件开始运行` | 原生覆盖 (BeginPlay) | 组件创建时由引擎自动触发 | 预留(当前无连线逻辑) | | `事件Tick` | 原生覆盖 | 每帧 | 预留(当前无连线逻辑) | | `事件OnCommandReceived` | 委托事件 (EndpointComponent) | 收到指令路由系统派发的 CommandPacket | 预留(当前无连线逻辑) | | `Server RPC` | 自定义事件 (RPC, Server) | 客户端触发时 | 获取 Owner → 按类获取 BP_InventoryComp → 读取 ItemCount → 获取 ItemViews → 遍历输出物品信息到屏幕 | **外部交互方式** - 作为 BP_TestChar 的组件自动创建 - 指令系统通过 UCommandRouter 将匹配标签的指令路由到该组件 - 外部系统无需直接与 BP_SayHello 交互 ## 使用方法 BP_SayHello 在项目中的典型调用流程: - **指令路由验证流程** — 测试输入触发 → UCommandRouter 路由指令到 BP_SayHello → OnCommandReceived 响应(当前未连线,为后续实现预留) - **库存调试流程** — 客户端触发 Server RPC 事件 → 获取 Owner → 按类查找 BP_InventoryComp → 读取 ItemCount 和 ItemViews → 逐条打印物品 ID、类型、名称到屏幕 ## 用例 | 引用方 | 路径 | 用途 | |--------|------|------| | BP_TestChar | `/Game/Blueprints/BP_TestChar` | 作为端点组件添加到角色,验证路由链路 | | BP_NewChar | `/Game/Blueprints/BP_NewChar` | 引用该组件参与指令系统测试 |