Skip to content

Game.Net.LaneSignal

Assembly:
Namespace: Game.Net

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents per-lane signaling state used by the game's traffic system. This struct is an ECS component (Unity.Entities.IComponentData) that stores which entity requested the signal (m_Petitioner), which entity is blocking it (m_Blocker), grouping and priority information, the lane signal type, and additional flags. It implements custom binary serialization/deserialization to maintain compatibility across save/game versions; several fields are read/written conditionally depending on Version constants (Version.trafficImprovements, Version.levelCrossing, Version.trafficFlowFixes).


Fields

  • public Entity m_Petitioner
    Represents the entity that requested or owns the signal for the lane. Serialized only when reader.context.version >= Version.trafficImprovements (in Deserialize). Used by traffic logic to track the requester of a held/queued signal.

  • public Entity m_Blocker
    Entity considered to be blocking the lane (for example another vehicle or building). Serialized only when reader.context.version >= Version.trafficImprovements (in Deserialize).

  • public ushort m_GroupMask
    Bitmask grouping lanes together for collective signaling/coordination. Always serialized.

  • public sbyte m_Priority
    Signed byte representing lane signal priority. Higher priority lanes may be serviced before lower ones. Always serialized.

  • public sbyte m_Default
    Default signal/state value (sbyte). This field is read/written only when reader.context.version >= Version.levelCrossing (added in that version).

  • public LaneSignalType m_Signal
    Enumerated type describing the current lane signal/state (stored in serialized form as a single byte). The enum defines what movement or permission is applied to the lane (e.g., allow/deny/priority states — see LaneSignalType definition for exact values).

  • public LaneSignalFlags m_Flags
    Bitflags providing extra metadata about the lane signal (stored in serialized form as a byte). This field is serialized/deserialized only when reader.context.version >= Version.trafficFlowFixes.

Properties

  • (none)
    This struct exposes no C# properties; all data is stored in public fields and accessed directly. It implements IQueryTypeParameter so it can be used in ECS queries.

Constructors

  • public LaneSignal()
    Default value-type constructor (implicit for structs). All fields will be initialized to their default values (Entity = default(Entity), numeric fields = 0, enums = default). No explicit custom constructor is defined in source.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the component data into a provided writer in a stable, versioned binary format. The implementation writes:
  • m_Petitioner (Entity)
  • m_Blocker (Entity)
  • m_GroupMask (ushort)
  • m_Priority (sbyte)
  • m_Default (sbyte)
  • m_Signal cast to byte
  • m_Flags cast to byte The writer side assumes the writer/context will handle any versioning on the save side. Note: writer.Write is used for the primitive and Entity values; enums are written as bytes.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads component data from reader with conditional logic depending on reader.context.version:

  • If reader.context.version >= Version.trafficImprovements: reads m_Petitioner and m_Blocker (Entity) first.
  • Always reads m_GroupMask (ushort) and m_Priority (sbyte).
  • If reader.context.version >= Version.levelCrossing: reads m_Default (sbyte).
  • Always reads a byte and casts it to LaneSignalType for m_Signal.
  • If reader.context.version >= Version.trafficFlowFixes: reads a byte and casts it to LaneSignalFlags for m_Flags. This method ensures backward compatibility with older save formats by only attempting to read fields that exist in that save version.

Usage Example

// Example: creating and serializing a LaneSignal instance (pseudo usage)
LaneSignal signal = new LaneSignal
{
    m_Petitioner = petitionerEntity,
    m_Blocker = blockerEntity,
    m_GroupMask = 0x0001,
    m_Priority = 5,
    m_Default = 0, // available since Version.levelCrossing
    m_Signal = LaneSignalType.Allow,
    m_Flags = LaneSignalFlags.None // available since Version.trafficFlowFixes
};

// Serialize with a writer that implements IWriter
myWriter.WriteContext(...); // set up context/version as needed
signal.Serialize(myWriter);

// Deserialize with a reader that implements IReader
LaneSignal loaded = new LaneSignal();
loaded.Deserialize(myReader);

{{ Additional notes: - This component is intended for internal traffic/AI systems and is typically attached to lane-related entities in the ECS world. - To understand the exact semantic values of LaneSignalType and LaneSignalFlags, consult their enum definitions in the codebase. - Be mindful of save version compatibility: when creating custom save/load tools or modifying serialization behavior, respect the existing version checks to maintain compatibility with existing saves. }}