Skip to content

Game.Prefabs.DefaultNetLane

Assembly:
Assembly-CSharp (may vary by build/mod; typically Assembly-CSharp.dll)

Namespace:
Game.Prefabs

Type:
struct (value type)

Base:
Unity.Entities.IBufferElementData

Summary:
Buffer element used by the game's ECS to represent a single lane entry for a "default net" prefab. Instances store a reference to the lane entity, its local/world position (float3), lane flags, and three small indices used by the net composition system (carriageway, group, index). The struct is marked with [InternalBufferCapacity(0)], meaning no elements are stored inline on the entity — elements are stored on the heap as a dynamic buffer. This type is intended for packaging lane composition data during prefab construction and for runtime code that iterates or modifies lane lists for a net prefab.


Fields

  • public Entity m_Lane
    Entity handle referencing the lane entity (Unity.Entities.Entity). This identifies the lane in the Entity Component System.

  • public float3 m_Position
    Position of the lane (Unity.Mathematics.float3). Typically used to store the lane's transform or a sampling point relevant for the net prefab.

  • public LaneFlags m_Flags
    LaneFlags enum/bitfield describing lane properties (directional flags, vehicle types allowed, etc.). The exact definition of LaneFlags is found elsewhere in the codebase.

  • public byte m_Carriageway
    Small integer identifying the carriageway index — used by net composition to group lanes by carriageway.

  • public byte m_Group
    Small integer for grouping lanes (logical grouping within a carriageway or prefab).

  • public byte m_Index
    Small integer index of the lane within its group/carriageway.

Properties

  • This type defines no properties. It is a plain IBufferElementData struct with public fields.

Constructors

  • public DefaultNetLane(NetCompositionLane source)
    Creates a DefaultNetLane from a NetCompositionLane source. Copies the lane entity, position, flags, and the carriageway/group/index bytes from the source composition struct. Useful when converting composition data into an ECS dynamic buffer of DefaultNetLane elements.

Methods

  • This type defines no methods beyond the generated value-type members (no custom methods or lifecycle callbacks).

Usage Example

// Example: filling a dynamic buffer on a prefab or entity with lanes.
// Assumes 'entityManager' and 'entity' are available and 'sourceLanes' is a collection of NetCompositionLane.

var buffer = entityManager.AddBuffer<Game.Prefabs.DefaultNetLane>(entity);

// For each source lane (NetCompositionLane), construct and add to the buffer:
foreach (var source in sourceLanes)
{
    var item = new Game.Prefabs.DefaultNetLane(source);
    buffer.Add(item);
}

// Reading back:
for (int i = 0; i < buffer.Length; i++)
{
    var lane = buffer[i];
    Entity laneEntity = lane.m_Lane;
    float3 pos = lane.m_Position;
    LaneFlags flags = lane.m_Flags;
    // use carriageway/group/index as needed
}

Notes and tips: - Because of [InternalBufferCapacity(0)], buffers of this element type are dynamically allocated; avoid frequently adding/removing single elements in performance-critical hot paths without considering buffer resizing costs. - This struct is intended to be lightweight and blittable to work efficiently with Unity's ECS. Keep added fields minimal. - The NetCompositionLane type is used to build these buffer entries; consult its definition to understand where this data originates (prefab assembly, net creation, etc.).