Skip to content

Game.Net.Segment

Assembly: Game
Namespace: Game.Net

Type: struct

Base: System.ValueType

Summary:
Represents the geometric description of a network segment's left and right side as cubic Bezier curves and a two-element length vector. This struct stores the left/right Bezier control data (Bezier4x3) and a float2 containing length values for the two ends of the segment. The read-only property middleLength interpolates those two length values to provide the length in the segment middle. Useful when working with road/track segment geometry and length-based calculations in modding scenarios.


Fields

  • public Bezier4x3 m_Left
    Stores the left-side Bezier curve for the segment. Bezier4x3 is a 4-point cubic Bezier with 3D control points (from Colossal.Mathematics) used to represent the left edge geometry of the segment.

  • public Bezier4x3 m_Right
    Stores the right-side Bezier curve for the segment. Used to represent the right edge geometry of the segment.

  • public float2 m_Length
    A two-component vector (Unity.Mathematics.float2) holding length values for the segment's two ends. Typical usage is treating m_Length.x and m_Length.y as the length at the start and end (or two sample positions) of the segment; the property middleLength interpolates between these.

Properties

  • public float middleLength { get; }
    Computed read-only property that returns the midpoint/interpolated length between m_Length.x and m_Length.y. Internally it uses math.lerp(m_Length.x, m_Length.y, 0.5f) (Unity.Mathematics). Equivalent to (m_Length.x + m_Length.y) * 0.5f, but expressed as a linear interpolation. Use this when you need a single representative length value for the center of the segment.

Constructors

  • public Segment()
    No explicit constructors are declared in the source; as a struct, Segment has the implicit default parameterless constructor that initializes fields to their default values (zeroed numeric values and default-initialized Bezier4x3).

Methods

  • None declared.
    The struct exposes only the public fields and the computed middleLength property; there are no instance methods in the provided source.

Usage Example

using Colossal.Mathematics;
using Unity.Mathematics;
using Game.Net;

public void Example()
{
    // Create a default segment (fields are default-initialized)
    Segment seg = new Segment();

    // Assign lengths at both ends
    seg.m_Length = new float2(10f, 14f);

    // Read the middle length (interpolated)
    float mid = seg.middleLength; // math.lerp(10f, 14f, 0.5f) => 12f

    // Assign left/right Bezier curves (Bezier4x3 constructor/signature depends on Colossal.Mathematics)
    // Example pseudo-assignment (replace with actual constructors/points as available):
    // seg.m_Left = new Bezier4x3(p0, p1, p2, p3);
    // seg.m_Right = new Bezier4x3(q0, q1, q2, q3);

    // Use seg in geometry calculations, rendering helpers, or pathing utilities.
}

Notes for modders: - Be mindful that Bezier4x3 is a Colossal.Mathematics type; consult its API for constructing and manipulating control points.
- m_Length values and how they're interpreted may depend on surrounding game logic (e.g., whether they represent physical length, scaled length, or other metrics). Inspect callers of Segment in game code to be certain.
- Modifying segment geometry or lengths at runtime can affect rendering and physics; test changes carefully to avoid visual or simulation glitches.