Skip to content

Game.Net.LabelPosition

Assembly: Assembly-CSharp
Namespace: Game.Net

Type: struct

Base: IBufferElementData, IEmptySerializable

Summary:
LabelPosition is a lightweight buffer element used by the net/road labelling system. It encodes a label's placement along a Bezier segment (m_Curve) and a small set of parameters that control how the label is rendered/scaled and whether it belongs to an underground segment. The struct is marked with [InternalBufferCapacity(0)], so it is intended to be used as a dynamic ECS buffer element (no inline capacity).


Fields

  • public Bezier4x3 m_Curve
    Stores the Bezier curve used to position the label. Bezier4x3 represents a cubic Bezier defined by four control points (typically in world space). This curve is used to compute the label's position and orientation along the net segment.

  • public int m_ElementIndex
    Index identifying which element (for example, which segment/lane-sub-element) this label belongs to. Used by the labelling system to tie the buffer element back to the net element it annotates.

  • public float m_HalfLength
    Half of the label's measured length along the curve. Useful for placement/clipping calculations and centering the label.

  • public float m_MaxScale
    Maximum allowed scale for the label. The rendering logic can use this to clamp scaling so labels do not become too large.

  • public bool m_IsUnderground
    Flag indicating whether the associated net element is underground. Labels for underground elements may be handled differently (hidden or drawn with special rules).

Properties

  • (none)
    This struct defines only fields; there are no properties.

Constructors

  • public LabelPosition()
    The default value-type constructor initializes fields to their default values (m_Curve = default, m_ElementIndex = 0, m_HalfLength = 0f, m_MaxScale = 0f, m_IsUnderground = false). Create and populate instances manually when adding to buffers.

Methods

  • (none)
    LabelPosition is a plain data container (POD) with no instance methods.

Additional Notes

  • Attribute: [InternalBufferCapacity(0)] — indicates the buffer has no inline storage and elements will be stored externally by the ECS dynamic buffer implementation.
  • Implements IBufferElementData so it is intended to be used in DynamicBuffer attached to an Entity (Unity.Entities).
  • Implements IEmptySerializable (game-specific marker) likely used by Colossal's serialization system to indicate the struct can be serialized in a special/empty-optimized way.

Usage Example

using Colossal.Mathematics;
using Unity.Entities;
using Unity.Mathematics; // if float3 is needed
using Game.Net;

// Example: add a LabelPosition buffer element to an entity
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity e = /* some net entity */ default;

// ensure the entity has a dynamic buffer for LabelPosition
if (!em.HasBuffer<LabelPosition>(e))
{
    em.AddBuffer<LabelPosition>(e);
}

DynamicBuffer<LabelPosition> buffer = em.GetBuffer<LabelPosition>(e);

// Construct a Bezier4x3 (pseudo; construct using your game's API/constructors)
Bezier4x3 curve = default; // populate with four control points appropriate for your game
// e.g. curve = new Bezier4x3(p0, p1, p2, p3); // replace with the actual constructor

LabelPosition lp = new LabelPosition {
    m_Curve = curve,
    m_ElementIndex = 0,
    m_HalfLength = 5.0f,
    m_MaxScale = 1.0f,
    m_IsUnderground = false
};

buffer.Add(lp);

{{ The LabelPosition buffer is used by the net labelling pipeline to store precomputed placement information for labels along road/track segments. When creating or updating nets, populate instances of this struct and add them to the entity's DynamicBuffer so downstream systems can read positioning, scaling, and visibility information efficiently in jobs. }}