Game.Net.ConnectionLane
Assembly: Assembly-CSharp
Namespace: Game.Net
Type: struct (implements IComponentData, IQueryTypeParameter, ISerializable, IEquatable
Base: System.ValueType
Summary:
Represents per-lane connection metadata used by the game's networking/serialization and ECS systems. Stores a reference to an access-restriction entity plus compact flags describing lane properties (connection flags, track types and — on newer versions — road types). Provides custom serialization/deserialization that is version-aware so saved data remains compatible across game versions, and an equality implementation that compares lane descriptors (excluding the access-restriction Entity).
Fields
-
public Entity m_AccessRestriction
Reference to an Entity that represents access restrictions for this lane (for example pathfinding or vehicle access restrictions). This field is serialized conditionally depending on the saved data version (checked against Version.pathfindAccessRestriction). Note: equality comparison intentionally ignores this field. -
public ConnectionLaneFlags m_Flags
Bitflags describing lane connection properties. Serialized as a uint. Used in Equals to compare lane identity. -
public TrackTypes m_TrackTypes
Compact enum describing track/rail type for the lane. Serialized as a single byte. Included in the equality comparison. -
public RoadTypes m_RoadTypes
Road type enum for the lane. Serialized as a single byte only when the reader/writer context version is at least Version.shipLanes. Included in the equality comparison.
Properties
- None (this struct exposes only public fields; no properties are declared).
Constructors
public ConnectionLane()
No explicit constructor is declared in the source; the default parameterless struct constructor is used. Fields will be default-initialized (m_AccessRestriction = default(Entity), enums = 0).
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the lane data into a writer in the following order:- m_AccessRestriction (Entity) — written unconditionally by this method, but note that deserialization only reads it when the saved data version supports it.
- m_Flags — written as a uint.
- m_TrackTypes — written as a byte.
-
m_RoadTypes — not written here explicitly unless the writer implementation/version expects it (the Deserialize expects a roadTypes byte when reader.context.version >= Version.shipLanes). In the source Serialize writes roadTypes as a byte as well. The method uses the generic writer constrained to IWriter so it can be used with different serialization backends.
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads lane data from reader in a version-aware manner: - If reader.context.version >= Version.pathfindAccessRestriction, reads an Entity into m_AccessRestriction.
- Always reads a uint (stored locally as value) which becomes m_Flags.
- Always reads a byte (stored locally as value2) which becomes m_TrackTypes.
- If reader.context.version >= Version.shipLanes, reads an additional byte (value3) and assigns it to m_RoadTypes.
-
Finally assigns the read values to m_Flags and m_TrackTypes (and m_RoadTypes when available). The method ensures backward compatibility by conditionally reading fields introduced in newer versions.
-
public bool Equals(ConnectionLane other)
Implements IEquatable. Returns true when m_Flags, m_TrackTypes, and m_RoadTypes are equal between the two instances. Note that m_AccessRestriction is not compared — equality compares only the lane descriptors, not the associated entity reference.
Usage Example
// Create and populate a ConnectionLane
ConnectionLane lane = new ConnectionLane
{
m_AccessRestriction = Entity.Null,
m_Flags = ConnectionLaneFlags.OneWay | ConnectionLaneFlags.CanTurn,
m_TrackTypes = TrackTypes.Road,
m_RoadTypes = RoadTypes.Standard
};
// Compare lanes
ConnectionLane other = lane;
bool same = lane.Equals(other); // true
// Serialization example (pseudocode; depends on actual IWriter implementation)
using (var writer = new BinaryWriterAdapter(stream, context))
{
lane.Serialize(writer); // writer must implement IWriter
}
// Deserialization example (pseudocode)
ConnectionLane loaded;
using (var reader = new BinaryReaderAdapter(stream, context))
{
loaded = default;
loaded.Deserialize(reader); // reader must implement IReader and provide context.version
}
Notes: - Equality intentionally ignores m_AccessRestriction; if you need to compare the actual referenced entity, compare m_AccessRestriction separately. - Serialization/deserialization logic is version-aware: Version.pathfindAccessRestriction and Version.shipLanes control whether access restriction and road type bytes are present/read. Ensure the reader/writer context.version is set appropriately when reading/writing saved data.