NetworkMapCodec
The wire and save format of NetworkMapBase contents (docs/replicated-collections.md D3).
Nebula · Packages/com.1by3.nebula/Runtime/Protocol/NetworkMapCodec.cspublic static class NetworkMapCodecThe wire and save format of NetworkMapBase contents (docs/replicated-collections.md D3). Keys and values are opaque, length-prefixed bytes, so a party with no game types (the gateway) can keep a map's contents and hand a late joiner a full copy.
body = [version:byte=1][flags:byte (1 = clear first)][count:int] { [op:byte (0 remove, 1 set)][keyLen:ushort][key]([valueLen:ushort][value]) }
section = [mapCount:byte] { [mapIndex:byte][bodyLength:int][body] }A full copy is a body with the clear flag set and every entry as a set. A delta is a body with only the keys that changed, each with its final state, so applying it to a copy that already contains it changes nothing.
Fields
Version
public const byte Version = 1;FlagClear
public const byte FlagClear = 1;OpRemove
public const byte OpRemove = 0;OpSet
public const byte OpSet = 1;HeaderBytes
public const int HeaderBytes = 6;Bytes of a body with no entries.
Methods
EntryBytes
public static int EntryBytes(int keyLength, int valueLength, bool set);The encoded size of one entry.
BeginBody
public static int BeginBody(NetworkWriter w, bool clear);Begin a body; returns where the count goes. Finish it with EndBody.
EndBody
public static void EndBody(NetworkWriter w, int countAt, int count);WriteSet
public static void WriteSet(NetworkWriter w, ArraySegment<byte> key, ArraySegment<byte> value);WriteRemove
public static void WriteRemove(NetworkWriter w, ArraySegment<byte> key);ReadBody
public static void ReadBody(NetworkReader r, out bool clear, List<Entry> into);Read a body: clear says whether the receiver empties its copy first, and each entry is added to into in order. Throws FormatException on a newer version.
BeginSection
public static int BeginSection(NetworkWriter w);Begin a section; returns where the map count goes.
BeginMap
public static int BeginMap(NetworkWriter w, byte mapIndex);Begin one map of a section; returns where its body length goes. Finish it with EndMap.
EndMap
public static void EndMap(NetworkWriter w, int lengthAt);EndSection
public static void EndSection(NetworkWriter w, int countAt, byte count);ReadSection
public static void ReadSection(ArraySegment<byte> section, Action<byte, ArraySegment<byte>> onMap);Walk a section: each map's index and body.
Nested types
Entry
public readonly struct EntryOne entry of a body as ReadBody hands it over. The segments point into the body.
Constructors
Entry
public Entry(bool isSet, ArraySegment<byte> key, ArraySegment<byte> value);Fields
IsSet
public readonly bool IsSet;Key
public readonly ArraySegment<byte> Key;Value
public readonly ArraySegment<byte> Value;NetworkMapCache
The contents of an entity's maps kept as opaque bytes, by a party that relays them without knowing their types: the gateway, so a late joiner is sent the current contents (docs/replicated-collections.md D6).
OwnerStateMsg
Authoritative post-simulation state of a predicted entity, for its owner's reconciliation.