Game.Net.MasterLane
Assembly: Assembly-CSharp
Namespace: Game.Net
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary: MasterLane is a small ECS component (IComponentData) used to identify and group lanes in the networking/serialization layer. It stores a lane group id and a min/max index for lanes inside that group. The struct implements ISerializable so it can be written/read by the game's serialization system and implements version-aware deserialization to preserve compatibility with older save/network formats.
Fields
-
public uint m_Group
Stores the group identifier for the lane(s). This is the single value that the current Serialize implementation writes out. Historically lane indexing changed across versions, so this field is subject to special handling during deserialization for backward compatibility. -
public ushort m_MinIndex
Minimum lane index within the group. Not written by Serialize (only kept in memory/for runtime use). -
public ushort m_MaxIndex
Maximum lane index within the group. Not written by Serialize (only kept in memory/for runtime use).
Properties
- This type defines no properties.
Constructors
public MasterLane()
No explicit constructor is defined in the source; the struct uses the default parameterless constructor provided by C#. Initialize fields directly when creating instances.
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes this MasterLane's data to the provided writer. Current implementation writes only m_Group:-
writer.Write(m_Group) Intended for the game's serialization pipeline; other fields (m_MinIndex/m_MaxIndex) are not serialized by this method in the given implementation.
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads data for this MasterLane from the provided reader. Behavior: - Reads m_Group into the struct.
- Performs a version check: if reader.context.version < Version.laneCountOverflowFix then it also reads two bytes (read into a temporary byte variable twice). This preserves compatibility with older formats where additional lane-count/format data existed. Notes:
- The extra reads for older versions discard values (read into a temporary) to maintain the reader stream position and compatibility.
- Ensure reader.context.version and Version.laneCountOverflowFix are available/defined in your mod context or rely on the game's versioning types.
Usage Example
// Example: create and add MasterLane as an ECS component
var masterLane = new MasterLane {
m_Group = 12345u,
m_MinIndex = 0,
m_MaxIndex = 3
};
// Using an EntityManager (Unity.Entities) to attach component to an entity:
entityManager.AddComponentData(entity, masterLane);
// Example: manual serialize/deserialize usage (pseudo-code; depends on the game's writer/reader types)
using (var writer = CreateGameWriter()) {
masterLane.Serialize(writer);
// writer now contains the serialized m_Group
}
using (var reader = CreateGameReader(byteStream)) {
var ml = new MasterLane();
ml.Deserialize(reader);
// ml.m_Group is restored; older format compatibility handled internally
}
Notes and Tips: - The serialization implementation only writes m_Group; if you need to persist m_MinIndex/m_MaxIndex, you must extend the serialization code accordingly (mind versioning). - The version check in Deserialize ensures older save/network formats are read without corrupting the stream — do not remove unless you control all versioned data formats. - Because this type implements IQueryTypeParameter and IComponentData, it can be used directly in Unity DOTS queries and systems.