Game.Prefabs.SecondaryNetLane
Assembly:
Assembly-CSharp (typical for game/mod assemblies; adjust if the type is in a different DLL)
Namespace:
Game.Prefabs
Type:
struct
Base:
Unity.Entities.IBufferElementData
Summary:
SecondaryNetLane is a buffer element type used with Unity's Entities (ECS) to store references to "secondary" lane entities and an associated flags value. The buffer is marked with InternalBufferCapacity(0), meaning it has no preallocated inline capacity and will allocate dynamically. This struct is intended to be attached to an entity as a dynamic buffer containing one or more lane references for use by net/prefab systems in Cities: Skylines 2 mod code.
Fields
-
public Unity.Entities.Entity m_Lane
Reference to the lane entity. This is the Entity handle that identifies the lane within the ECS world. -
public SecondaryNetLaneFlags m_Flags
Flags associated with the lane entry. Typically an enum (bitmask) used to indicate properties/roles of this secondary lane (e.g., direction, usage, special handling). The actual definition of SecondaryNetLaneFlags is elsewhere in the codebase.
Properties
- None (this type is a plain buffer element with public fields; no properties are defined)
Constructors
- Implicit parameterless constructor (default)
No explicit constructors are declared. Instances are created by the ECS buffer system or can be constructed by value when adding to a DynamicBuffer.
Methods
- None (no instance or static methods are defined on this struct)
Notes and Implementation Details
- Attribute: [InternalBufferCapacity(0)] — this sets the inline capacity of the dynamic buffer to 0 elements. Use this if typical element count varies widely or you want minimal per-entity footprint until elements are added.
- Because this implements IBufferElementData, it is intended to be used with EntityManager/GetBuffer or via Entities.ForEach that injects a DynamicBuffer
. - Keep components that reference Entities small and plain (value types), as done here (Entity + small enum/flags) to keep job safety and structural changes efficient.
Usage Example
// Add a SecondaryNetLane dynamic buffer to an entity, then add an element.
// using Unity.Entities;
EntityManager mgr = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity someEntity = /* the entity that should hold the buffer */;
// Ensure the entity has the buffer component
if (!mgr.HasComponent<SecondaryNetLane>(someEntity))
mgr.AddBuffer<SecondaryNetLane>(someEntity);
// Get the dynamic buffer and add a lane reference
var buffer = mgr.GetBuffer<SecondaryNetLane>(someEntity);
SecondaryNetLane element = new SecondaryNetLane
{
m_Lane = laneEntity, // laneEntity is an Entity representing the lane
m_Flags = SecondaryNetLaneFlags.None // or appropriate flags value
};
buffer.Add(element);
If you need to access or modify the buffer inside a System, prefer using DynamicBuffer