Skip to content

Game.Prefabs.SubLane

Assembly:
Namespace: Game.Prefabs

Type: struct

Base: Unity.Entities.IBufferElementData

Summary:
SubLane is a plain ECS buffer element that describes one sub-lane belonging to a lane prefab/mesh. It is marked with [InternalBufferCapacity(0)] so instances are stored in a DynamicBuffer on an entity with no inline capacity (fully heap-backed). The struct holds a reference to a prefab Entity, the geometry of the lane as a cubic Bezier, and small integer indices used to associate the sub-lane with node/mesh data.


Fields

  • public Entity m_Prefab
    Reference to the prefab Entity for this sub-lane (usually an entity representing the visual/mesh prefab to instantiate or to use as template).

  • public Bezier4x3 m_Curve
    The lane geometry expressed as a Bezier4x3 (from Colossal.Mathematics). This encodes the cubic Bezier control points in 3D space and is used to evaluate positions/tangents along the sub-lane.

  • public int2 m_NodeIndex
    A pair of integer indices (Unity.Mathematics.int2). Typically used to store node-related indices (for example start/end node indices or an index/slot pair) — the exact interpretation depends on the consuming system.

  • public int2 m_ParentMesh
    A pair of integer indices identifying the parent mesh or mesh slot this sub-lane belongs to. Used to map the sub-lane back to larger mesh structures.

Properties

  • (none)
    This struct contains only public fields and implements IBufferElementData; there are no properties.

Constructors

  • public SubLane()
    Implicit parameterless constructor provided by the struct. Create an instance and set fields manually before adding to a DynamicBuffer.

Methods

  • (none)
    No methods are defined on this struct; it is a pure data container intended for storage in an ECS DynamicBuffer.

Usage Example

// Example: adding a SubLane to an entity's DynamicBuffer in a SystemBase or similar.
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity someEntity = /* an entity that will own the sub-lanes */;

// Ensure the entity has a DynamicBuffer<SubLane>
if (!entityManager.HasComponent<SubLane>(someEntity))
{
    entityManager.AddBuffer<SubLane>(someEntity);
}

var buffer = entityManager.GetBuffer<SubLane>(someEntity);

// Create and populate a SubLane
SubLane sub = new SubLane
{
    m_Prefab = prefabEntity,
    m_Curve = new Bezier4x3(
        p0: new float3(0,0,0),
        p1: new float3(1,0,0),
        p2: new float3(2,0,0),
        p3: new float3(3,0,0)
    ),
    m_NodeIndex = new int2(12, 34),
    m_ParentMesh = new int2(1, 0)
};

// Add to the buffer
buffer.Add(sub);

Additional notes: - Because SubLane implements IBufferElementData it should be stored/retrieved via DynamicBuffer. - Bezier4x3 is provided by Colossal.Mathematics and offers methods for curve evaluation; use it to compute positions/tangents for rendering or placement. - The semantics of m_NodeIndex and m_ParentMesh are project-specific; consult systems that consume SubLane for exact meanings.