Obstacle.h
Source/MassBattle/Public/Fragments/Obstacle.h
概述 Overview
四种障碍物实体 fragment:胶囊体 FCapsuleObstacle、盒体 FBoxObstacle、样条 FSplineObstacle 与网络联结 FObstacleNetBinding。前三个 fragment 持有对应 UMassBattleObstacle*Component 的绑定指针、静态/注册标志与锁步同步信息;样条障碍物额外携带锁步采样点数据(LocalSamplePoints + WorldBase* + bFlipDirection),使网格读实体而非 UObject,保证双端一致。FObstacleNetBinding 是命令路由障碍物的快照联结键,镜像 FAgentController.LockstepNetID 模式,使快照恢复后的实体可被宿主组件重绑。
Four obstacle entity fragments: capsule FCapsuleObstacle, box FBoxObstacle, spline FSplineObstacle and the network binding FObstacleNetBinding. The first three hold the bound UMassBattleObstacle*Component pointer, static/registered flags and lockstep sync info; the spline additionally carries lockstep sample data (LocalSamplePoints + WorldBase* + bFlipDirection) so the grid reads the entity instead of the UObject, keeping peers identical. FObstacleNetBinding is the snapshot join key for command-routed obstacles, mirroring the FAgentController.LockstepNetID pattern so a restored entity can be re-bound by its host component.
FCapsuleObstacle USTRUCT
胶囊体障碍物 fragment,派生自 FA_MassBattleBaseFragment,声明为不可平凡拷贝。持有 UMassBattleObstacleCapsuleComponent 绑定指针。
Capsule obstacle fragment derived from FA_MassBattleBaseFragment, declared not-trivially-copyable. Holds the bound UMassBattleObstacleCapsuleComponent pointer.
成员变量 Members
| 名称 Name | 类型 Type | 默认值 | 说明 Description |
|---|---|---|---|
bOverrideSpeedLimit | bool | true | 是否覆盖速度上限(网格数据中的 bOverrideSpeedLimit 来源)。Whether the speed limit is overridden (source of bOverrideSpeedLimit in grid data). |
bStatic | bool | false | 是否静态障碍物。Whether this is a static obstacle. |
bRegistered | bool | false | 是否已注册进 HashGrid。Whether registered into the HashGrid. |
bLockstepSynced | bool | false | 锁步命令同步标记——同步后网格读实体而非 UObject。Lockstep command-synced — the grid reads the entity, not the UObject. |
BoundComponent | UMassBattleObstacleCapsuleComponent* | nullptr | 绑定的胶囊体组件指针。Bound capsule component pointer. |
方法 Methods
返回 BoundComponent。
Returns BoundComponent.
Input
无参数。
No parameters.
Output
返回绑定组件指针(可能为 nullptr)。
Returns the bound component pointer (may be nullptr).
FObstacleNetBinding USTRUCT
命令路由障碍物的联结节 fragment,派生自 FA_MassBattleBaseFragment,镜像 FAgentController.LockstepNetID 模式:服务器在组件注册时分配 ID、经组件复制、快照于此,使恢复端实体可被宿主组件重绑(RebindToEntity 扫描此字段)。联结方式:复制 owner 用 NetID 联结;非复制的地图障碍物保持 NetID=-1,改以 ComponentPath 联结(双端地图构造保证同一路径上持有同一地图 Actor——快照化前的清单重放已验证此解析)。本地路径障碍物不携带此片段——无 FNetworkTag,不进快照/hash/统一查询。
Join-key fragment for command-routed obstacles, derived from FA_MassBattleBaseFragment, mirroring the FAgentController.LockstepNetID pattern: the server allocates the ID at component registration, replicates it via the component and snapshots it here so a restored entity can be re-bound by its host component (RebindToEntity scans this field). Join rules: replicated owners join by NetID; non-replicated MAP obstacles keep NetID=-1 and join by ComponentPath instead (both peers hold the same map actor at the same path — the pre-snapshot manifest replay proved this resolution). Local-path obstacles carry no such fragment — without FNetworkTag they stay out of snapshot/hash/unified queries.
继承 Inheritance
成员变量 Members
| 名称 Name | 类型 Type | 默认值 | 说明 Description |
|---|---|---|---|
LockstepNetID | int32 | -1 | 命令路由障碍物联结节——服务器分配、经组件复制、快照于此供重绑扫描(BlueprintReadOnly)。非复制地图障碍物保持 -1,改用 ComponentPath 联结。Command-routed obstacle join key — server-allocated, replicated via the component, snapshotted here for the rebind scan (BlueprintReadOnly). Non-replicated map obstacles keep -1 and join by ComponentPath instead. |
ComponentPath | FName | NAME_None | 绑定组件的对象路径——非复制地图障碍物的路径联结键,其余类型的诊断身份。存储为归一化值(世界分隔号 ':' 之后的子路径):PIE 世界前缀每端不同(UEDPIE_x_…),原始路径跨端永不匹配(见 UMassBattleObstSubsystem::NormalizeObstacleJoinPath)。经 UPROPERTY 快照同步(DirectName);不入 hash(联结键而非模拟状态)。Object path of the bound component — path join key for non-replicated map obstacles and diagnostic identity for the rest. Stored normalized (sub-path after the world ':'): PIE world prefixes differ per peer (UEDPIE_x_…), so raw paths never match cross-peer (see UMassBattleObstSubsystem::NormalizeObstacleJoinPath). Snapshot-synced via UPROPERTY (DirectName); NOT hashed (join key, not simulation state). |
FBoxObstacle USTRUCT
盒体障碍物 fragment,派生自 FA_MassBattleBaseFragment,声明为不可平凡拷贝。提供默认构造与参数构造(参数顺序与成员声明顺序完全匹配)。
Box obstacle fragment derived from FA_MassBattleBaseFragment, declared not-trivially-copyable. Provides a default ctor and a parameter ctor (parameter order exactly matches member declaration order).
成员变量 Members
| 名称 Name | 类型 Type | 默认值 | 说明 Description |
|---|---|---|---|
bStatic | bool | false | 是否静态障碍物。Whether this is a static obstacle. |
bRegistered | bool | false | 是否已注册进 HashGrid。Whether registered into the HashGrid. |
BoundComponent | UMassBattleObstacleBoxComponent* | nullptr | 绑定的盒体组件指针。Bound box component pointer. |
方法 Methods
参数构造:初始化 bStatic 与 BoundComponent。
Parameter ctor: initializes bStatic and BoundComponent.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
InStatic | const bool& | 静态标记。Static flag. |
InBoundComponent | UMassBattleObstacleBoxComponent* | 绑定的盒体组件。Bound box component. |
Output
无返回值。副作用:初始化两个成员。
No return value. Side effect: initializes the two members.
返回 BoundComponent。
Returns BoundComponent.
Input
无参数。
No parameters.
Output
返回绑定组件指针(可能为 nullptr)。
Returns the bound component pointer (may be nullptr).
FSplineObstacle USTRUCT
样条障碍物 fragment,派生自 FA_MassBattleBaseFragment,声明为不可平凡拷贝。除组件绑定外,携带锁步动态障碍物同步数据:注册时在组件空间捕获采样点,WorldBase* 为 Obstacle.SyncTransform 锁步命令同步的组件基准;段数注册时固定,运行时禁止增删点。
Spline obstacle fragment derived from FA_MassBattleBaseFragment, declared not-trivially-copyable. Besides component binding it carries lockstep dynamic-obstacle sync data: sample points captured in component space at registration, with WorldBase* being the component base synced by the Obstacle.SyncTransform lockstep command; segment count is fixed at registration — runtime point add/remove is forbidden.
成员变量 Members
| 名称 Name | 类型 Type | 默认值 | 说明 Description |
|---|---|---|---|
bStatic | bool | false | 是否静态障碍物。Whether this is a static obstacle. |
bRegistered | bool | false | 是否已注册进 HashGrid。Whether registered into the HashGrid. |
BoundComponent | UMassBattleObstacleSplineComponent* | nullptr | 绑定的样条组件指针。Bound spline component pointer. |
LocalSamplePoints | TArray<FVector3f> | 空 | 注册时在组件空间捕获的采样点。经 UPROPERTY 快照同步。Sample points captured in component space at registration. Snapshot-synced via UPROPERTY. |
WorldBaseLoc | FVector3f | (0,0,0) | 锁步同步的组件基准位置。经 UPROPERTY 快照同步。Component base location synced via lockstep. Snapshot-synced via UPROPERTY. |
WorldBaseRot | FQuat4f | Identity | 锁步同步的组件基准旋转。经 UPROPERTY 快照同步。Component base rotation synced via lockstep. Snapshot-synced via UPROPERTY. |
bFlipDirection | bool | false | 命令路由标志镜像——服务器捕获进命令载荷/快照 blob,网格读此字段而绝不读各端活组件(bFlipDirection 非复制属性)。Command-routed flag mirror — server-captured into the command payload / snapshot blob; the grid reads this field, never the live per-peer component (bFlipDirection is not a replicated property). |
方法 Methods
参数构造:初始化 bStatic 与 BoundComponent。
Parameter ctor: initializes bStatic and BoundComponent.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
InStatic | const bool& | 静态标记。Static flag. |
InBoundComponent | UMassBattleObstacleSplineComponent* | 绑定的样条组件。Bound spline component. |
Output
无返回值。副作用:初始化两个成员。
No return value. Side effect: initializes the two members.
返回 BoundComponent。
Returns BoundComponent.
Input
无参数。
No parameters.
Output
返回绑定组件指针(可能为 nullptr)。
Returns the bound component pointer (may be nullptr).
管线角色 Pipeline Role
grep 验证:三个 fragment 被 MassBattleObstSubsystem(组件绑定、注册/同步)、MassBattleGridUpdateProcessor(注册进 HashGrid 生成 FCapsuleObstGridData 等网格数据)与 MassBattleNetworkGameStateBase 引用。
Verified by grep: the three fragments are referenced by MassBattleObstSubsystem (component binding, registration/sync), MassBattleGridUpdateProcessor (registers into the HashGrid producing FCapsuleObstGridData and friends) and MassBattleNetworkGameStateBase.