SyncStateCodec
Envelope shared by the per-tick sync stream (EntityState/GhostSyncState messages) and the spawn snapshot: [count]{[behaviourIndex][flags][len:ushort][chunk]}.
Nebula · Packages/com.1by3.nebula/Runtime/Core/SyncState.cspublic static class SyncStateCodecEnvelope shared by the per-tick sync stream (EntityState/GhostSyncState messages) and the spawn snapshot: [count]{[behaviourIndex][flags][len:ushort][chunk]}. Each chunk is bounded so a behaviour that reads too much or too little cannot corrupt its neighbours. Kept free of NetworkIdentity so the gateway can cache keyframes without instantiating anything.
Methods
AudienceOf
public static SyncAudience AudienceOf(ChunkFlags flags);The audience a chunk's flags carry.
FlagsOf
public static ChunkFlags FlagsOf(SyncAudience audience);The flag bits that carry audience; none for SyncAudience.Everyone.
IsRestricted
public static bool IsRestricted(ChunkFlags flags);Whether the flags name an audience that limits which clients receive the chunk (anything but SyncAudience.Everyone).
BeginEnvelope
public static int BeginEnvelope(NetworkWriter w);EndEnvelope
public static void EndEnvelope(NetworkWriter w, int countAt, byte count);WriteChunk
public static void WriteChunk(NetworkWriter w, byte behaviourIndex, ChunkFlags flags, NetworkBehaviour b, bool full);WriteRawChunk
public static void WriteRawChunk(NetworkWriter w, byte behaviourIndex, ChunkFlags flags, ArraySegment<byte> chunk);ReadEnvelope
public static void ReadEnvelope(NetworkReader r, ChunkVisitor visit);Nested types
ChunkFlags
[Flags]
public enum ChunkFlags : byteLists the supported chunk flags values.
Members
| Name | Value | Description |
|---|---|---|
None | 0 | |
Full | 1 | The chunk is a keyframe: everything the behaviour replicates, not just what changed. |
AudienceOwner | 1 << 1 | Bits 1 and 2 hold the behavior's SyncAudience (AudienceMask). Zero is SyncAudience.Everyone, so a chunk of an unrestricted behavior is byte for byte what it was before audiences existed. The gateway filters on these bits; workers and clients ignore them. |
AudienceWorkersOnly | 2 << 1 | See AudienceOwner: the chunk is for workers only. |
AudienceCustom | 3 << 1 | See AudienceOwner: the chunk is for the member set the authority sent (SyncAudienceMsg). |
AudienceMask | 3 << 1 | The two audience bits. |
Cleared | 1 << 3 | Gateway to client, protocol 20 and later: this client left the behavior's audience. The chunk is empty. The client calls NetworkBehaviour.OnSyncStateCleared instead of ReadSyncState. |
DistanceRated | 1 << 4 | Worker to gateway: the behavior's state follows the entity's distance tier (SyncDistanceRating, docs/server-owned-entities.md D11). The gateway sends such a chunk to a client beyond its every-update band only as a keyframe, one per window of the client's rate. Clients ignore the bit. |
Settled | 1 << 5 | Worker to gateway, with DistanceRated and Full, on the reliable stream: the keyframe a rated behavior writes once it has stopped changing. The gateway sends it to every client that holds the entity, whatever its distance, so a coalesced client ends with the latest state. Clients ignore the bit. |
ChunkVisitor
public delegate void ChunkVisitor(byte behaviourIndex, ChunkFlags flags, ArraySegment<byte> chunk);SyncHistoryAttribute
Marks a NetworkVariable<T> field as part of the entity's recorded state history, so its value is snapshotted every tick alongside the pose and can be read back through NetworkIdentity.StateAt / HistoricalState.TryGetValue<T>.
UpdateGapDelay
The extra render delay a client gives one remote entity whose state arrives further apart than the render delay: an entity the worker updates every few ticks (NetworkIdentity.UpdateInterval), or one the gateway sends a client only every ...