Game.Net.LaneReservation
Assembly: Assembly-CSharp.dll
Namespace: Game.Net
Type: struct
Base: System.ValueType, IComponentData, IQueryTypeParameter, ISerializable
Summary: LaneReservation represents a small data container used by the networking/traffic system to track lane reservations. It stores an optional blocker Entity and two ReservationData entries (m_Next and m_Prev) that capture reservation offset and priority information for the next and previous reservation on the lane. It provides convenience accessors to obtain a normalized offset and the effective priority, and implements custom serialization/deserialization to be transmitted over the network. Note: offsets are packed as bytes and converted to a normalized float by multiplying by 1/255 (0.003921569f).
Fields
-
public Entity m_Blocker
Represents an Entity that blocks the lane reservation (e.g., a vehicle or obstacle). This field is serialized conditionally depending on the serialized version in Deserialize (only read when reader.context.version >= Version.stuckTrainFix). -
public ReservationData m_Next
Reservation data for the "next" reservation on the lane. ReservationData holds at least a byte m_Offset and a byte m_Priority (not defined in this file). m_Next is used as one source for offset/priority computations and is serialized. -
public ReservationData m_Prev
Reservation data for the "previous" reservation on the lane. Like m_Next, it provides offset and priority and is serialized.
Properties
- This type does not define any C# properties (only public fields and methods).
Constructors
- The struct has no explicit constructors in source; the default parameterless constructor (value-initialized fields) is used. When created, m_Blocker will be default(Entity) and m_Next/m_Prev will be default(ReservationData).
Methods
-
public float GetOffset()
Returns the normalized offset to use for this reservation. Implementation: takes the maximum of m_Next.m_Offset and m_Prev.m_Offset (both bytes), casts to int, and multiplies by 0.003921569f (1/255f) to convert the byte value into a 0..1 float range. -
public int GetPriority()
Returns the effective priority for this reservation. Implementation: returns the maximum of m_Next.m_Priority and m_Prev.m_Priority (both bytes), cast to int. -
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the reservation fields to the writer in a defined order: - m_Blocker (Entity)
- m_Next.m_Offset (byte)
- m_Next.m_Priority (byte)
- m_Prev.m_Offset (byte)
-
m_Prev.m_Priority (byte) This ordering must be matched by Deserialize.
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads data in a matching order. Important detail: m_Blocker is only read when reader.context.version >= Version.stuckTrainFix — older serialized data may omit the blocker field. Then reads m_Next.m_Offset, m_Next.m_Priority, m_Prev.m_Offset, m_Prev.m_Priority. Fields are read by reference into the struct's fields.
Usage Example
// Constructing and using LaneReservation
var reservation = new LaneReservation();
reservation.m_Blocker = Entity.Null; // or some blocking entity
reservation.m_Next = new ReservationData { m_Offset = 128, m_Priority = 2 };
reservation.m_Prev = new ReservationData { m_Offset = 64, m_Priority = 1 };
float normalizedOffset = reservation.GetOffset(); // max(128,64)/255f -> ~0.50196f
int priority = reservation.GetPriority(); // max(2,1) -> 2
// Serializing (pseudo-example; writer must implement IWriter)
writer.Write(reservation.m_Blocker);
writer.Write(reservation.m_Next.m_Offset);
writer.Write(reservation.m_Next.m_Priority);
writer.Write(reservation.m_Prev.m_Offset);
writer.Write(reservation.m_Prev.m_Priority);
// Deserialization must respect version check: older data may not include m_Blocker
// (the reader implementation used in the game checks reader.context.version against Version.stuckTrainFix)