Game.Net.SlaveLane
Assembly: Assembly-CSharp (game runtime assembly)
Namespace: Game.Net
Type: struct
Base: System.ValueType, IComponentData, IQueryTypeParameter, ISerializable
Summary: Represents a "slave" lane record used by the game's lane grouping / networking code. Holds flags, a group identifier, index ranges and sub/master indices. Implements Unity.Entities.IComponentData so instances can be attached to ECS entities, and implements custom binary serialization via Colossal.Serialization.Entities.ISerializable. The serialization logic stores the flags (as a uint), the group id, and the sub-index; Deserialize contains a compatibility path for older save versions (Version.laneCountOverflowFix), reading the sub-index as either a ushort or a byte depending on version.
Fields
-
public SlaveLaneFlags m_Flags
Flags describing the slave lane state. Serialized as a uint in Serialize/Deserialize (cast to/from uint). -
public uint m_Group
Group identifier for this lane. Written and read directly during serialization. -
public ushort m_MinIndex
Minimum lane index for this slave (not serialized by the provided Serialize method). -
public ushort m_MaxIndex
Maximum lane index for this slave (not serialized by the provided Serialize method). -
public ushort m_SubIndex
Sub-index of the lane within a group. Serialized, and read in Deserialize in a version-aware manner (ushort for newer versions, legacy byte for older versions). -
public ushort m_MasterIndex
Index of the master lane this slave is associated with (not serialized by the provided Serialize method).
Properties
- This type has no public properties. It exposes fields directly.
Constructors
public SlaveLane()
Default parameterless struct constructor (value-type defaults). All numeric fields default to zero; flags default to the default value of SlaveLaneFlags.
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the SlaveLane to the provided writer. The implementation writes:- m_Flags cast to uint
- m_Group (uint)
-
m_SubIndex (ushort) Note: m_MinIndex, m_MaxIndex and m_MasterIndex are not written by this method.
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads data back in the same order. The method: - Reads a uint (stored temporarily and later cast into m_Flags).
- Reads m_Group (uint).
- For versions >= Version.laneCountOverflowFix: reads m_SubIndex as ushort. For older versions: reads one byte for the subIndex and another byte (ignored); assigns the first byte into m_SubIndex.
- Assigns m_Flags from the initially read uint. This method is version-aware to preserve compatibility with older saved data formats.
Usage Example
// Create and attach a SlaveLane component to an entity (Unity.Entities)
var slave = new Game.Net.SlaveLane
{
m_Flags = SlaveLaneFlags.None,
m_Group = 42u,
m_SubIndex = 3,
m_MinIndex = 0,
m_MaxIndex = 10,
m_MasterIndex = 1
};
// entityManager is a Unity.Entities.EntityManager; entity is a created Entity
entityManager.AddComponentData(entity, slave);
// Serialization example (pseudocode; depends on concrete writer implementation)
var writer = /* obtain a IWriter implementation from serialization context */;
slave.Serialize(writer);
// Deserialization example (pseudocode)
var reader = /* obtain a IReader implementation from serialization context */;
Game.Net.SlaveLane loaded;
loaded.Deserialize(reader);
entityManager.SetComponentData(entity, loaded);
Additional notes: - Because only a subset of fields is serialized, the non-serialized fields must be reconstructed or are considered ephemeral/derivable at load time. - The version check for Version.laneCountOverflowFix is important for compatibility with older saves where sub-index was stored in a smaller size. Ensure the reader.context.version is set appropriately when deserializing saved data.