๐งฉ AutoReplication Mixin
Short Description
Lightweight mixin that binds AutoReplication data to Quality-of-Life classes and manages replicated entries.
Long Description
The mixin stores Object Variable entries, allocates replication slots, and routes queued RPCs to the correct target. It is embedded in QoL classes (player controller, game state, etc.) and bridges between Object Variables and network components.
๐ Features
- Additional data entries that store default Object Variables and stream overrides.
- Replicated variable slots with deterministic indices.
- RPC queueing and dispatch hooks for Blueprint responders.
๐ Usage Examples
AutoReplicationMixin.InitializeAdditionalData(true);
AutoReplicationMixin.DispatchPendingRPCs();
Implement Handle AutoReplication RPC on your QoL class to respond to queued RPCs.
InitializeAdditionalData
Initializes the mixin entries and optionally activates networking, allocating replication slots as needed.
| Parameter Name | Type | Description |
|---|---|---|
bActivateNetworkingCapabilities |
bool |
Whether to activate networking and register streams. |
AutoReplicationMixin.InitializeAdditionalData(true);
RequestRPC
Queues an AutoReplication RPC request routed through the owning class and its registered variables.
| Parameter Name | Type | Description |
|---|---|---|
Key |
FName |
AutoReplication entry key. |
Type |
EGorgeousAutoReplicationRPCType |
Route type (server/client/multicast). |
Payload |
FGorgeousRPCPayload |
RPC payload to dispatch. |
TargetKind |
EGorgeousAutoReplicationTargetKind |
Target kind override. |
FGuid RequestId;
AutoReplicationMixin.RequestRPC(TEXT("Inventory"), EGorgeousAutoReplicationRPCType::EReliableServer, Payload, EGorgeousAutoReplicationTargetKind::EAuto, &RequestId);
Best Practices
- Call the helper macros to initialize additional data and replication arrays.
- Use entry keys that remain stable across sessions.
Troubleshooting
- If entries are missing, ensure the mixin is bound to
AdditionalGorgeousDataand replicated arrays. - If RPC queues never drain, verify the responder interface is implemented on the owning class.