Skip to content

Game.Prefabs.TrackComposition

Assembly: Game (may be part of the main game assembly / Assembly-CSharp.dll)
Namespace: Game.Prefabs

Type: struct

Base: System.ValueType, Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter

Summary:
Component used by the game's ECS to describe basic track properties for a prefab track segment. Holds the track type identifier and an associated speed limit. This component is lightweight and intended to be attached to entities representing track pieces so systems can query track characteristics (type and allowed speed) during simulation, routing and rendering logic.


Fields

  • public TrackTypes m_TrackType
    Identifies which kind of track this entity represents. TrackTypes is an enum (defined elsewhere) that distinguishes different rail/track categories (for example different vehicle types, visual variants or infrastructure categories). Systems use this value to decide compatibility, visuals, and behaviour.

  • public float m_SpeedLimit
    Speed limit applied to this track segment. Expressed in the game's internal speed units (used by vehicle movement systems). This value is consulted by traffic and vehicle systems to cap or influence vehicle speeds when traveling on this track.

Properties

  • None. This type exposes plain public fields rather than properties to keep the component data blittable and efficient for the ECS.

Constructors

  • Implicit default constructor (value-initialized)
    Structs in C# provide a default constructor that initializes fields to their default values (m_TrackType = default(TrackTypes), m_SpeedLimit = 0f). You can also create and set values via an object initializer.

Methods

  • None. This is a plain data component without behavior. Logic that acts on TrackComposition instances lives in systems that read this IComponentData.

Usage Example

// Create a TrackComposition and attach it to an entity (EntityManager example)
var trackComp = new TrackComposition {
    m_TrackType = TrackTypes.Rail,   // replace with actual enum member
    m_SpeedLimit = 20f               // set an appropriate speed limit
};

entityManager.AddComponentData(trackEntity, trackComp);

// Querying in a system (example)
Entities
    .WithAll<TrackComposition>()
    .ForEach((ref TrackComposition track) =>
    {
        // read track.m_TrackType and track.m_SpeedLimit here
    }).Run();