MassBattle Docsv1.19.20

UMassBattleEntityComponentBase

UCLASS

Source/MassBattle/Public/Components/MassBattleEntityComponentBase.h

概述 Overview

实体绑定组件(Agent / Projectile / Loot)的共享基类,派生自 USceneComponent。承载三块职责:LockstepNetID 生命周期(服务器分配、UE 复制、客户端 OnRep 自注册进宿主注册表、resync 重链入口)、tick/基础设施骨架(子系统惰性缓存、TickComponent 的 bPendingRebind 重试 + SyncTransform 分发、刚体父子附着的初始相对变换捕获)、以及同步模式字段(LocationSyncMode / RotationSyncMode / ScaleSyncMode,默认实体驱动组件)。子类各自保留实体的生成/销毁、变换同步数学与事件逻辑。锁步会话(IsLockstepSession():客户端始终走锁步栈,服务器/单机读网络 GameMode 的 bEnableNetworkSync)下组件自动 SetIsReplicated(true),基类 BeginPlay 统一执行 ID 预分配与 ValidateNetworkConfig 门控校验。

Shared base class for entity-bound components (Agent / Projectile / Loot), derived from USceneComponent. Owns three responsibilities: the LockstepNetID lifecycle (server allocation, UE replication, client self-registration into the host registry on OnRep, resync re-link entry), the tick/infrastructure skeleton (lazy subsystem caches, bPendingRebind retry + SyncTransform dispatch in TickComponent, initial relative transform capture for rigid parent-child attachment), and the sync-mode fields (LocationSyncMode / RotationSyncMode / ScaleSyncMode, entity-to-component by default). Subclasses keep their entity-specific spawn/despawn, transform-sync math and event logic. In a lockstep session (IsLockstepSession(): clients always ride the lockstep stack; server/standalone read the network GameMode's bEnableNetworkSync) the component auto-enables SetIsReplicated(true), and base BeginPlay runs ID pre-allocation plus ValidateNetworkConfig gate checks uniformly.

继承 Inheritance

USceneComponent → UMassBattleEntityComponentBase

派生类:UMassBattleAgentComponent、UMassBattleLootComponent、UMassBattleProjectileComponent。

Derived classes: UMassBattleAgentComponent, UMassBattleLootComponent, UMassBattleProjectileComponent.

公开方法 Public Methods

UMassBattleEntityComponentBase 构造函数

开启组件 tick(bCanEverTick / bStartWithTickEnabled 均为 true),并将移动性设为 Movable —— 运行时写世界变换的前提。

Enables component ticking (both bCanEverTick and bStartWithTickEnabled true) and sets mobility to Movable — required for runtime world-transform writes.

Input

无参数。

No parameters.

Output

无返回值。副作用:tick 使能与移动性设置。

No return value. Side effects: tick enablement and mobility setting.

IsLockstepSession bool () const

会话驱动的锁步参与判定(与 BeginPlay 派发顺序无关),委托共享静态实现 UMassBattleSubsystem::IsLockstepSession(GetWorld())(单一事实源,障碍物组件/子系统按同一位路由):客户端(NM_Client)始终返回 true——锁步会话无退出项;服务器/单机读网络 GameMode(AMassBattleNetworkGameModeBase)的 bEnableNetworkSync 配置。替代已移除的每组件 bLockstepNetworked 开关。适用于任意 Owner(玩家 Pawn、AI Pawn、炮塔等),不限于玩家。

Session-driven lockstep participation check (order-independent of BeginPlay dispatch), delegating to the shared static UMassBattleSubsystem::IsLockstepSession(GetWorld()) (single source of truth — obstacle components/subsystem route on the same bit): clients (NM_Client) always return true — networked sessions have no opt-out; server/standalone read the network GameMode's (AMassBattleNetworkGameModeBase) bEnableNetworkSync config. Replaces the removed per-component bLockstepNetworked switch. Works for any owner (player pawn, AI pawn, turret, etc.) — not limited to players.

Input

无参数。

No parameters.

Output

返回当前是否处于锁步会话。无副作用。

Returns whether the current session is a lockstep session. No side effects.

GetEntityHandle FEntityHandle (BlueprintPure)

返回本组件绑定的实体句柄;未初始化时句柄无效(Index/Serial 为 0)。Blueprint 可用。

Returns the entity handle bound to this component; invalid (Index/Serial zero) when not initialized. Blueprint-accessible.

Input

无参数。

No parameters.

Output

返回 EntityHandle。无副作用。

Returns EntityHandle. No side effects.

IsInitialized bool (BlueprintPure, DisplayName = "Is Initialized")

查询当前是否已绑定实体(读 bIsMassInitialized)。Blueprint 中以 "Is Initialized" 名称暴露。

Queries whether an entity is currently bound (reads bIsMassInitialized). Exposed to Blueprint as "Is Initialized".

Input

无参数。

No parameters.

Output

返回布尔绑定状态。无副作用。

Returns the binding state as bool. No side effects.

GetInitialRelativeLocation const FVector&

返回绑定时组件在实体局部空间中的相对位置(公开只读,供网络预测使用)。

Returns the entity-local relative location captured at bind time (public read, for network prediction).

Input

无参数。

No parameters.

Output

返回 InitialRelativeLocation 引用。无副作用。

Returns a reference to InitialRelativeLocation. No side effects.

OnRep_LockstepNetID void (UFUNCTION)

LockstepNetID 经 UE 复制到达客户端的回调:自注册进宿主注册表(RegisterSelfToNetworkRegistry),使锁步 spawn 指令能通过该 ID 找到本组件;随后调用一次 RebindToEntity() 尝试重链 —— 组件可能晚于 resync 快照到达,若重建实体尚未出现,由子类每帧 bPendingRebind 重试接管。

Replication callback when LockstepNetID arrives on the client: self-registers into the host registry (RegisterSelfToNetworkRegistry) so lockstep spawn commands can find this component by ID, then attempts one RebindToEntity() — the component may arrive after the resync snapshot, in which case the subclass per-frame bPendingRebind retry takes over.

Input

无参数。

No parameters.

Output

无返回值。副作用:宿主注册表登记;触发一次重链尝试。

No return value. Side effects: host registry registration; one rebind attempt.

EnsureLockstepNetIDAllocated void

仅服务器路径:若 LockstepNetID 尚未分配(< 0),从 UMassBattleNetworkSubsystem::AllocNextLockstepNetID() 分配并自注册。幂等;owner 无权威或网络子系统缺失时直接返回。使用独立计数器(NextLockstepNetID),不碰通用实体 UID 槽位分配器(FEntityUIDAllocator)。

Server-only path: if LockstepNetID is not yet allocated (< 0), allocates via UMassBattleNetworkSubsystem::AllocNextLockstepNetID() and self-registers. Idempotent; returns silently when the owner lacks authority or the network subsystem is missing. Uses an independent counter (NextLockstepNetID) — never touches the general-entity UID slot allocator (FEntityUIDAllocator).

Input

无参数。

No parameters.

Output

无返回值。副作用:分配一个 LockstepNetID 并注册进宿主注册表。

No return value. Side effects: allocates one LockstepNetID and registers into the host registry.

RebindToEntity virtual void

快照恢复后把组件重链到重建实体。基类为空实现;子类实现实体查找(agent 按 FAgentController.LockstepNetID 扫描,projectile/loot 按各自 UID 反查)并重绑。由 resync 重链 pass 与每帧 bPendingRebind 重试调用;幂等。

Re-links this component to its rebuilt entity after snapshot restore. Base implementation is empty; subclasses implement the entity lookup (agents scan FAgentController.LockstepNetID; projectile/loot look up by their own UIDs) and re-bind. Called by the resync re-link pass and the per-frame bPendingRebind retry; idempotent.

Input

无参数。

No parameters.

Output

无返回值。子类实现可能设置 bPendingRebind = true(实体未恢复)。

No return value. Subclass implementations may set bPendingRebind = true (entity not restored yet).

GetMassAPISubsystem UMassAPISubsystem*

惰性访问器:命中缓存直接返回;否则解析 GetWorld() 写入 CurrentWorld,再从世界取 UMassAPISubsystem 写入缓存。

Lazy accessor: returns the cache on hit; otherwise resolves GetWorld() into CurrentWorld and fetches UMassAPISubsystem from the world into the cache.

Input

无参数。

No parameters.

Output

返回子系统指针(世界缺失时可能为 nullptr)。副作用:写入两个缓存成员。

Returns the subsystem pointer (may be nullptr when the world is missing). Side effect: fills the two cache members.

GetMassBattleSubsystem UMassBattleSubsystem*

惰性访问器:语义与 GetMassAPISubsystem 相同,目标为 UMassBattleSubsystem。

Lazy accessor: same semantics as GetMassAPISubsystem, targeting UMassBattleSubsystem.

Input

无参数。

No parameters.

Output

返回子系统指针(世界缺失时可能为 nullptr)。副作用:写入缓存。

Returns the subsystem pointer (may be nullptr when the world is missing). Side effect: fills the cache.

BeginPlay virtual void (protected)

锁步会话入口:先调用父类,然后若 IsLockstepSession() 为 true —— ① SetIsReplicated(true) 开启组件复制(使 LockstepNetID 可复制);② EnsureLockstepNetIDAllocated() 服务器预分配路由 ID(Auto/Manual 在此统一);③ ValidateNetworkConfig() 校验锁步/权威配置(在 SetIsReplicated 之后调用,门控 4 才能读到组件复制的生效状态)。

Lockstep-session entry: calls the parent first, then when IsLockstepSession() is true — ① SetIsReplicated(true) enables component replication (so LockstepNetID can replicate); ② EnsureLockstepNetIDAllocated() pre-allocates the routing ID on the server (Auto/Manual unified here); ③ ValidateNetworkConfig() checks lockstep/authority configuration (runs after SetIsReplicated so gate 4 sees the effective component-replication state).

Input

无参数。

No parameters.

Output

无返回值。副作用:组件复制开启、ID 分配、配置校验(失败以 Error 日志输出,不崩溃)。

No return value. Side effects: component replication enabled, ID allocation, config validation (failures logged as Error, no crash).

EndPlay virtual void (protected)

先调用 UnregisterSelfFromNetworkRegistry()(组件即将销毁,必须先从宿主注册表注销),再调用父类。

Calls UnregisterSelfFromNetworkRegistry() first (the component is going away, so it must leave the host registry), then the parent implementation.

Input
参数 Param类型 Type说明 Description
EndPlayReasonEEndPlayReason::Type结束播放原因。End-play reason.
Output

无返回值。副作用:宿主注册表注销。

No return value. Side effect: host registry unregistration.

GetLifetimeReplicatedProps virtual void (protected)

声明 LockstepNetID 参与复制(DOREPLIFETIME),并转发父类。

Declares LockstepNetID for replication (DOREPLIFETIME) and forwards to the parent.

Input
参数 Param类型 Type说明 Description
OutLifetimePropsTArray<FLifetimeProperty>&复制属性列表,由引擎传入。Replicated property list, provided by the engine.
Output

无返回值。副作用:向列表追加 LockstepNetID。

No return value. Side effect: appends LockstepNetID to the list.

TickComponent virtual void (protected)

每帧 tick:① 调用父类;② 若 bPendingRebind 为 true 则调用 RebindToEntity()(快照 resync 可能先于组件复制到达;RebindToEntity 幂等,每帧重试安全,直至恢复实体出现);③ 若已初始化(bIsMassInitialized),依次执行 SyncTransform(DeltaTime) 与 OnEntityTick(DeltaTime)。

Per-frame tick: ① calls the parent; ② if bPendingRebind is true, calls RebindToEntity() (snapshot resync may race ahead of component replication; RebindToEntity is idempotent so per-frame retry is safe until the restored entity appears); ③ when initialized (bIsMassInitialized), runs SyncTransform(DeltaTime) then OnEntityTick(DeltaTime).

Input
参数 Param类型 Type说明 Description
DeltaTimefloat本帧时间步长(秒)。Frame delta time in seconds.
TickTypeELevelTicktick 类型(引擎传入)。Tick type (engine-provided).
ThisTickFunctionFActorComponentTickFunction*tick 函数对象(引擎传入)。Tick function object (engine-provided).
Output

无返回值。副作用:重链重试;向子类分发变换同步与实体 tick。

No return value. Side effects: rebind retry; dispatches transform sync and entity tick to subclasses.

SyncTransform virtual void (protected, InDeltaTime = 0.f)

按当前同步模式执行实体↔组件变换同步。基类为空实现;子类实现实体类型专属数学(Agent 的完整 E2A/FF/相对变换版本,Loot/Projectile 的直贴版本)。

Applies entity↔component transform sync per the current sync modes. Base implementation is empty; subclasses implement the entity-type-specific math (Agent's full E2A/FF/relative-transform version; Loot/Projectile's direct-copy version).

Input
参数 Param类型 Type说明 Description
InDeltaTimefloat时间步长(秒),当前基类未使用。Delta time in seconds; currently unused by the base.
Output

无返回值。基类无副作用。

No return value. No side effects in the base.

OnEntityTick virtual void (protected)

变换同步后每 tick 的实体类型专属逻辑。基类为空实现;Loot 子类用它做状态机事件轮询(状态变更时广播收集/销毁事件)。

Per-tick entity-type-specific logic after transform sync. Base implementation is empty; the Loot subclass uses it for state-machine event polling (broadcasting collect/destroy events on state changes).

Input
参数 Param类型 Type说明 Description
InDeltaTimefloat时间步长(秒)。Delta time in seconds.
Output

无返回值。基类无副作用。

No return value. No side effects in the base.

ResetSyncModes void (protected)

把三个同步模式全部重置为 None。用于反初始化路径 —— 池化复用可能稍后重新初始化,不允许残留同步方向。

Resets all three sync modes to None. Used on the deinit path — pooling may re-init later, so no sync direction may linger.

Input

无参数。

No parameters.

Output

无返回值。副作用:三个同步模式成员复位。

No return value. Side effect: all three sync-mode members reset.

CaptureRelativeTransforms void (protected)

捕获绑定时组件/Actor↔实体的相对变换,用于刚性父子附着。从实体读 FRotating.RotationQuat 与 FLocating.Location 构成实体世界变换;计算并缓存:组件相对变换 InitialRelativeTransform(组件世界 = 初始相对变换 * 实体世界)与其逆、实体局部相对位置 InitialRelativeLocation(始终为 (0,0,-GroundOffset) 语义,随实体当前朝向旋转),以及 Actor 版本三件套。MA 或实体句柄无效时直接返回。

Captures bind-time Component/Actor↔Entity relative transforms for rigid parent-child attachment. Reads FRotating.RotationQuat and FLocating.Location from the entity to form its world transform; computes and caches: the component relative transform InitialRelativeTransform (ComponentWorld = InitialRelativeTransform * EntityWorld) and its inverse, the entity-local relative location InitialRelativeLocation (always (0,0,-GroundOffset) semantics, rotated by the entity's current orientation), plus the Actor variant trio. Returns early when MA or the entity handle is invalid.

Input
参数 Param类型 Type说明 Description
ComponentWTconst FTransform&绑定时组件世界变换。Component world transform at bind time.
ActorWTconst FTransform&绑定时 Actor 世界变换。Actor world transform at bind time.
Output

无返回值。副作用:写入 InitialRelativeTransform / InverseInitialRelativeTransform / bInitialRelativeTransformValid / InitialRelativeLocation,以及 Actor 版本四个成员(存在 owner 时)。

No return value. Side effects: writes InitialRelativeTransform / InverseInitialRelativeTransform / bInitialRelativeTransformValid / InitialRelativeLocation, plus the four Actor-variant members (when an owner exists).

UpdateFastForwardState bool (protected)

FF(快进)检测:读 UMassBattleNetworkSubsystem::bFastForwarding,与上一帧缓存 bCachedFFState 做边沿比较;进入/退出 FF 时切换 Owner 的 ReplicateMovement(FF 开始保存原值并关闭,FF 结束恢复 —— 实体权威模式下禁止 UE 复制双轨驱动 actor 位置)。返回当前 FF 状态。

FF (fast-forward) detection: reads UMassBattleNetworkSubsystem::bFastForwarding and compares against the cached bCachedFFState for edge detection; on FF enter/exit it toggles the Owner's ReplicateMovement (saved at FF start and disabled; restored at FF end — the entity-authoritative mode forbids dual-track actor position driving via UE replication). Returns the current FF state.

Input

无参数。

No parameters.

Output

返回当前是否处于 FF。副作用:边沿时修改 bCachedFFState 与 Owner 的 ReplicateMovement(经 SetReplicatingMovement)。

Returns whether FF is active. Side effects: on edges, updates bCachedFFState and the Owner's ReplicateMovement (via SetReplicatingMovement).

EffectiveSyncMode EMassAgentSyncMode (protected)

有效同步模式:FF 时把 ComponentToEntity 映射为 EntityToActor —— 由现有 EntityToActor 分支吸附 actor;ComponentToEntity 写回分支因 EffMode != ComponentToEntity 被跳过。非 FF 时原样返回。

Effective sync mode: during FF, maps ComponentToEntity to EntityToActor so the existing EntityToActor branch snaps the actor; ComponentToEntity write-back branches are skipped because EffMode != ComponentToEntity. Returns the mode unchanged outside FF.

Input
参数 Param类型 Type说明 Description
ModeEMassAgentSyncMode原始同步模式。The raw sync mode.
Output

返回 FF 映射后的有效模式。无副作用。

Returns the FF-mapped effective mode. No side effects.

ValidateNetworkConfig void (protected)

网络配置校验,配置错误时以 Error 级别日志响亮失败(不崩溃)。四道门控:① 锁步要求 owner actor 开启复制——违反时硬拦截:置 bNetworkSpawnBlocked,非复制 owner 的 spawn 指令在客户端永远找不到组件(无限延迟重试),因此组件不得注册进 pending-spawn 队列、不得发送 spawn 指令;② 豁免 —— ComponentToEntity 由组件驱动实体,actor 位置复制可选;③ 实体权威同步模式(EntityToComponent/EntityToActor)下 owner 不得开启 ReplicateMovement(双轨位置冲突);④ 锁步要求组件自身开启复制(LockstepNetID 才能到达客户端)。由基类 BeginPlay 在 SetIsReplicated(true) 之后调用。

Network configuration validation — fails loud via Error-level logs (no crash) on misconfigured lockstep/authority setups. Four gates: ① lockstep requires the owner actor to replicate — violation hard-blocks by setting bNetworkSpawnBlocked: a spawn command for a non-replicated owner can never find its component on clients (infinite defer-retry), so the component must not register into the pending-spawn queue nor send one; ② exempt — ComponentToEntity drives the entity from the component, so actor position replication is optional; ③ entity-authoritative modes (EntityToComponent/EntityToActor) must not have ReplicateMovement on the owner (dual-track position conflict); ④ lockstep requires component replication itself (so LockstepNetID reaches clients). Called from base BeginPlay after SetIsReplicated(true).

Input

无参数。

No parameters.

Output

无返回值。副作用:违规时输出 [LOCKSTEP] Error 日志。

No return value. Side effect: [LOCKSTEP] Error logs on violations.

RegisterSelfToNetworkRegistry void (protected)

按 LockstepNetID 把本组件登记进共享宿主注册表(UMassBattleNetworkSubsystem::RegisterLockstepHost);网络子系统缺失或 ID 未分配(< 0)时无操作。

Registers this component into the shared host registry by LockstepNetID (UMassBattleNetworkSubsystem::RegisterLockstepHost); no-op when the network subsystem is missing or the ID is unallocated (< 0).

Input

无参数。

No parameters.

Output

无返回值。副作用:宿主注册表写入。

No return value. Side effect: host registry write.

UnregisterSelfFromNetworkRegistry void (protected)

按 LockstepNetID 从宿主注册表注销(UMassBattleNetworkSubsystem::UnregisterLockstepHost);条件与注册相同。

Removes this component from the host registry by LockstepNetID (UMassBattleNetworkSubsystem::UnregisterLockstepHost); same conditions as registration.

Input

无参数。

No parameters.

Output

无返回值。副作用:宿主注册表删除。

No return value. Side effect: host registry removal.

成员变量 Members

LockstepNetID int32 (UPROPERTY, ReplicatedUsing = OnRep_LockstepNetID, 默认 -1)

服务器分配的锁步路由 ID,UE 复制。用作注册表键(指令→宿主查找),agent/projectile/loot 组件使用;replicated actor 也可同样分配使用。与实体 UID(锁步本地分配)相互独立。

Server-assigned lockstep routing ID, UE-replicated. Used as the registry key (command→host lookup) by agent/projectile/loot components; replicated actors may allocate and use it the same way. Independent from the entity UID (which is lockstep-allocated locally).

LocationSyncMode EMassAgentSyncMode (UPROPERTY, 默认 EntityToComponent)

位置同步模式,默认实体驱动组件。取值见 MassBattleEnums.h 的 EMassAgentSyncMode。Loot 保留旧 bool 三开关(单向子集),不读这些字段。

Location synchronization mode; entity-to-component by default. Values in EMassAgentSyncMode (see MassBattleEnums.h). Loot keeps its legacy three bools (one-way subset) and does not read these fields.

RotationSyncMode EMassAgentSyncMode (UPROPERTY, 默认 EntityToComponent)

旋转同步模式,默认实体驱动组件。

Rotation synchronization mode; entity-to-component by default.

ScaleSyncMode EMassAgentSyncMode (UPROPERTY, 默认 EntityToComponent)

缩放同步模式,默认实体驱动组件。

Scale synchronization mode; entity-to-component by default.

bCachedFFState bool (protected, 默认 false)

FF 缓存:上一帧 FF 状态,供 UpdateFastForwardState 边沿检测。

FF cache: last-frame FF state for edge detection in UpdateFastForwardState.

bReplicateMovementSaved bool (protected, 默认 false)

FF 缓存:FF 开始时保存的 Owner ReplicateMovement 原值,FF 结束时恢复。

FF cache: the Owner's ReplicateMovement saved at FF start and restored at FF end.

InitialRelativeTransform FTransform (protected, 默认 Identity)

初始相对变换:绑定时组件世界相对于实体世界的变换。恒等式:组件世界 = 初始相对变换 * 实体世界。初始化时捕获一次,保持恒定以实现刚性父子附着。

Initial relative transform: Component world relative to Entity world at bind time. Identity: ComponentWorld = InitialRelativeTransform * EntityWorld. Captured once at initialization and kept constant for rigid parent-child attachment.

InverseInitialRelativeTransform FTransform (protected, 默认 Identity)

预计算的逆变换:实体世界相对于组件世界的变换。恒等式:实体世界 = 逆初始相对变换 * 组件世界。

Precomputed inverse: Entity world relative to Component world at bind time. Identity: EntityWorld = InverseInitialRelativeTransform * ComponentWorld.

bInitialRelativeTransformValid bool (protected, 默认 false)

初始相对变换是否已计算。SyncTransform 以其为前置条件之一。

Whether InitialRelativeTransform has been computed. One of SyncTransform's preconditions.

ActorInitialRelativeTransform FTransform (protected, 默认 Identity)

初始相对变换的 Actor 版本:绑定时 Actor 世界相对于实体世界的变换。当本组件不是根组件时与 InitialRelativeTransform 不同。

Actor variant of the initial relative transform: Actor world relative to Entity world at bind time. Differs from InitialRelativeTransform when this component is not the root component.

InverseActorInitialRelativeTransform FTransform (protected, 默认 Identity)

Actor 版本的预计算逆变换:实体世界相对于 Actor 世界。

Actor variant of the precomputed inverse: Entity world relative to Actor world.

bActorInitialRelativeTransformValid bool (protected, 默认 false)

Actor 初始相对变换是否已计算。

Whether ActorInitialRelativeTransform has been computed.

InitialRelativeLocation FVector (protected, 默认 ZeroVector)

实体局部相对位置:绑定时组件在实体局部空间中的位置。无论倾斜与否始终为 (0, 0, -GroundOffset);每帧随实体当前朝向旋转。

Entity-local relative location: component position in the entity's local space at bind time. Always (0, 0, -GroundOffset) regardless of tilt; rotated by the entity's current rotation each frame.

ActorInitialRelativeLocation FVector (protected, 默认 ZeroVector)

Actor 的实体局部相对位置。

Entity-local relative location for the actor.

CurrentWorld TObjectPtr<UWorld> (protected, mutable, 默认 nullptr)

运行时缓存的当前世界,首次访问子系统时惰性解析。

Runtime-cached current world; lazily resolved on first subsystem access.

MassAPISubsystem TObjectPtr<UMassAPISubsystem> (protected, mutable, 默认 nullptr)

运行时缓存的 Mass API 子系统指针。

Runtime-cached UMassAPISubsystem pointer.

MassBattleSubsystem TObjectPtr<UMassBattleSubsystem> (protected, mutable, 默认 nullptr)

运行时缓存的 MassBattle 子系统指针。

Runtime-cached UMassBattleSubsystem pointer.

bPendingRebind bool (protected, 默认 false)

实体尚未恢复时置 true(快照 resync 先于本组件复制到达)。TickComponent 每帧重试 RebindToEntity 直至绑定收敛。纯本地运行时状态 —— 不复制、不进快照。

True while the entity is not yet restored (snapshot resync raced ahead of this component's replication). TickComponent retries RebindToEntity each frame until the binding converges. Local runtime state only — never replicated, never snapshotted.

bNetworkSpawnBlocked bool (protected, 默认 false)

由 ValidateNetworkConfig 门控 1(owner actor 未开启复制)置位:锁步生成被硬拦截——组件不得注册进 pending-spawn 队列、不得发送 spawn 指令(否则客户端会对永不复制的组件无限延迟重试)。子类(Agent / Projectile / Loot Component)的 Auto 初始化与手动生成路径均检查该位。纯本地运行时状态。

Set by ValidateNetworkConfig gate 1 (owner actor does not replicate): lockstep spawn is HARD-BLOCKED — the component must not register into the pending-spawn queue nor send a spawn command (clients would defer-retry forever on a component that never replicates). Both the Auto-init and the manual spawn paths of the subclasses (Agent / Projectile / Loot Component) check this bit. Local runtime state only.

bIsMassInitialized bool (protected, 默认 false)

当前是否已绑定实体。

Whether an entity is currently bound to this component.

EntityHandle FEntityHandle (protected)

绑定的实体句柄,反初始化时清零(Index/Serial = 0)。

The bound entity handle, zeroed on deinit (Index/Serial = 0).

管线角色 Pipeline Role

在锁步网络管线中的位置:BeginPlay 在锁步会话(IsLockstepSession(),替代已移除的每组件 bLockstepNetworked)时开启组件复制 → EnsureLockstepNetIDAllocated 从 UMassBattleNetworkSubsystem 分配路由 ID → 服务器端组件经 GameMode(SendLockstepCommandToClients)广播 Spawn 锁步指令(owner 未开启复制时经 bNetworkSpawnBlocked 硬拦截) → LockstepNetID 复制到客户端触发 OnRep_LockstepNetID 自注册,使指令执行端能经注册表(RegisterLockstepHost/UnregisterLockstepHost)反查本组件 → 快照恢复后,resync 重链 pass 对注册表中每个宿主调用 RebindToEntity()(见 UMassBattleNetworkSubsystem 的重链段);晚于该 pass 到达的组件经 OnRep + 每帧 bPendingRebind 重试自行重链。每帧 TickComponent 在初始化后分发 SyncTransform(实体↔组件变换同步,FF 期间实体权威)与 OnEntityTick(子类事件轮询)。

Position in the lockstep network pipeline: BeginPlay enables component replication in a lockstep session (IsLockstepSession(), replacing the removed per-component bLockstepNetworked) → EnsureLockstepNetIDAllocated allocates the routing ID from UMassBattleNetworkSubsystem → the server-side component broadcasts the Spawn lockstep command via the GameMode (SendLockstepCommandToClients; hard-blocked via bNetworkSpawnBlocked when the owner does not replicate) → LockstepNetID replicates to clients, triggering OnRep_LockstepNetID self-registration so the command-execution side can look this component up via the registry (RegisterLockstepHost/UnregisterLockstepHost) → after snapshot restore, the resync re-link pass calls RebindToEntity() on every registered host (see UMassBattleNetworkSubsystem); components arriving later than that pass re-link themselves via OnRep plus the per-frame bPendingRebind retry. Each frame TickComponent dispatches SyncTransform (entity↔component transform sync; entity-authoritative during FF) and OnEntityTick (subclass event polling) once initialized.