Skip to content

Game.Prefabs.NetPieceData

Assembly:
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter

Summary:
NetPieceData is an ECS component struct used by Cities: Skylines 2 to hold geometric and placement-related parameters for a "net piece" prefab (road/track/pipe segment, etc.). It stores height bounds, per-corner surface heights and basic dimensional offsets used by placement, connection and rendering systems. Values are in engine/game units (typically meters or Unity units depending on game context).


Fields

  • public Colossal.Mathematics.Bounds1 m_HeightRange
    Represents the allowed or measured vertical range for the piece. Used to determine placement constraints and snapping relative to terrain or adjacent pieces. Initialize with appropriate min/max values from the Colossal.Mathematics.Bounds1 API.

  • public Unity.Mathematics.float4 m_SurfaceHeights
    Holds four surface height values (typically the heights at the piece's corners or key sample points). Used to blend the piece to terrain or to other pieces. The ordering of components (x, y, z, w) corresponds to the code that reads these values in placement or mesh generation systems.

  • public float m_Width
    The full width of the piece. Used for collision, rendering and spacing calculations.

  • public float m_Length
    The intended length of the piece along its primary axis. Used for spacing pieces along a path and for mesh scaling.

  • public float m_WidthOffset
    An offset to apply to width calculations (e.g., for aligning the mesh relative to a centerline or adjusting sidewalk/border offsets).

  • public float m_NodeOffset
    Offset applied near nodes (endpoints) of the piece. Used to control how the piece connects to nodes or adjacent pieces, influencing alignment and visual gaps.

  • public float m_SideConnectionOffset
    Offset used for side connections (e.g., connections to side pieces, railings or lanes). Adjusts where side-connections attach relative to the main piece geometry.

Properties

  • None (this struct exposes public fields and does not declare properties)

Constructors

  • Implicit default constructor (public NetPieceData()) — default struct initialization; fields should be set explicitly when used.

Methods

  • None (no methods declared on this component type)

Usage Example

// Example: create an entity with NetPieceData and set sample values.
// Requires using Unity.Entities, Unity.Mathematics and Colossal.Mathematics.

var em = World.DefaultGameObjectInjectionWorld.EntityManager;
var entity = em.CreateEntity(typeof(Game.Prefabs.NetPieceData));

em.SetComponentData(entity, new Game.Prefabs.NetPieceData
{
    // Initialize height range appropriately using the Bounds1 API:
    m_HeightRange = default, // set min/max via Bounds1 API as needed

    // Four surface heights (corner/sample heights)
    m_SurfaceHeights = new float4(0f, 0f, 0f, 0f),

    m_Width = 6f,
    m_Length = 10f,
    m_WidthOffset = 0f,
    m_NodeOffset = 0.5f,
    m_SideConnectionOffset = 0.25f
});

Notes: - When populating m_HeightRange, use the constructors/properties provided by Colossal.Mathematics.Bounds1 (the example uses default for clarity). - The meanings of the surface height components and exact usage of offsets depend on the systems that read this component (placement/mesh generation/connection logic). Adjust values experimentally while testing in-game.