Skip to main content

Replication and Events

Cube Weapon replicates actor data and component state, then rebuilds client-side visual components. Its local subsystem maps are not themselves replicated objects.

Source: Private/WorldActors/WeaponActorBase_Replication.cpp, Private/Data/WeaponStructs.cpp, Private/Components/AC_WeaponNetComp_*.cpp and Private/Components/AC_WeaponCharComp.cpp.

Replicated State​

OwnerProperties
AWeaponActorBaseActorNetGuid, BuildID, WeaponRuntimeData, RuntimeStats
UAC_WeaponNetCompWorkingBuild
UAC_WeaponCharCompAssignedWeaponActors, ActualUsedWeapon
UAC_WeaponGameplayCompWeaponStateData

WeaponRefCache, ActiveComponentMap, AvailableSockets and free mesh-component lists are local reconstruction state. ActualAmmo is not a replicated property.

Runtime Fast Array​

FWeaponDataArray derives from FFastArraySerializer and uses FWeaponDataEntry items with EntryID, InstanceID, DBType, MeshType and SocketName. NetDeltaSerialize uses FastArrayDeltaSerialize; the owner back-reference is NotReplicated.

Item callbacks PostReplicatedAdd, PostReplicatedChange and PreReplicatedRemove call the actor's data-listener functions, which assign/reset local components. Array callbacks notify the actor of final sizes. Actor OnRep_WeaponDataArray also assigns entries absent from its ActiveComponentMap.

Clients load definitions by ID and reconstruct meshes on the replicated actor. They do not spawn an additional actor for every received build or mesh part.

FWeaponStateArray similarly serializes gameplay-state tags and notifies the gameplay component through its state-listener interface. State changes can start/stop the local fire loop.

RPC Routes​

RouteClient behaviorAuthority behavior
BuildSRPC_QueueBuildRequestExecutes internal build handler
AcquireSRPC_QueueAcquireRequestExecutes allocation handler
Equip/Unequip/UseSRPC_QueueEquipRequestExecutes equipment handler
InteractionExecutes local handler, then SRPC_QueueInteractRequestExecutes interaction handler

Ranged attack and reload use reliable multicasts. Their implementations skip an autonomous owner because that client has already executed the local interaction. Firemode change updates the state array through its interaction path rather than an equivalent dedicated multicast.

This provides local responsiveness but is not a complete prediction/reconciliation or authoritative ammunition system. Test event execution separately on authority, owning clients and simulated proxies.

Build Delegates​

DelegateParametersEmitted by
OnWorkingBuildModifiedOldBuild, NewBuildMutateWorkingBuild on authority operation paths
OnWorkingBuildReplicatedOldBuild, NewBuildClient OnRep_WorkingBuild
OnWorkingBuildCreatedBuildIDClient RepNotify when GUID changes, including import/reset transitions
OnBuildValidatedCallbackBuildIDSuccessful authority validation and client callback RPC
FetchBuildCallbackBuildCRPC_FetchBuildCallback after local registration

OnWorkingBuildCreated means the replicated GUID changed, not exclusively that CreateBuild ran. It can carry an empty GUID on reset. BuildCreatedCallback on the controller interface is declared but not invoked by the create handler.

A validation callback supplies a GUID, not the complete build. WorkingBuild replication and RPC delivery should be coordinated independently; do not assume all replicated fields are ready simply because a callback arrived.

Actor and Character Events​

EventContract
WeaponAcquiredCallbackActor OnRep_Owner for locally controlled owner, when GUID is already valid
OnActorNetGuidReplicated(ActorRef)Successful registration in OnRep_ActorNetGuid when previously unregistered
WeaponUnequipCallbackAuthority cleanup handoff from Unequip
OnUsedWeaponUpdate(OldWeapon, NewWeapon)Character active-weapon state changes
OnWeaponFired(WeaponRef)Gameplay fire loop consumes a shot
OnWeaponStateChanged(bAddTag, ChangedTag)Declared on the actor; not a general replacement for emitted component state events

OnRep_ActorNetGuid does not retry WeaponAcquiredCallback if OnRep_Owner ran before the GUID arrived. Internal acquisition also lacks an authority-side completion callback. Project handoff logic must account for those differences.

Gameplay Tags and Thread Context​

Native weapon state tags are defined in Public/Data/WeaponTags.h and Private/Data/WeaponTags.cpp. Keep slot tags and state tags distinct, and use the exact tags expected by the fire/state handlers.

Use UObject gameplay APIs on the game thread. Asynchronous streaming does not make registries, build mutation or runtime components a thread-safe worker API. No locks or cross-thread gameplay mutation contract are provided by these managers.