Skip to content

Game.Prefabs.WaterwayComposition

Assembly: Game
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter

Summary:
A lightweight ECS component that stores waterway-specific configuration for an entity — currently contains a single field for a speed limit. Intended for use with Unity.Entities (DOTS) queries and systems in the Cities: Skylines 2 modding environment. Because it implements IComponentData it can be attached to entities; implementing IQueryTypeParameter allows it to be used directly in query parameter lists.


Fields

  • public float m_SpeedLimit
    Represents the speed limit for the waterway. Set this to the desired speed value when attaching the component to an entity. Units follow the game's internal speed conventions (check surrounding APIs for whether values are in m/s, km/h, or game units).

Properties

  • This type does not declare any properties. It exposes a single public field (m_SpeedLimit).

Constructors

  • public WaterwayComposition()
    No explicit constructors are defined in the source; the default parameterless constructor is provided by the compiler. Initialize the m_SpeedLimit field via an object initializer or by assigning after construction.

Methods

  • This struct defines no instance or static methods. It only serves as a data container for ECS.

Usage Example

// Add the component to an existing entity with a speed limit:
var comp = new WaterwayComposition { m_SpeedLimit = 10f };
entityManager.AddComponentData(waterwayEntity, comp);

// Read and modify in a SystemBase:
public partial class WaterwaySystem : SystemBase
{
    protected override void OnUpdate()
    {
        Entities.ForEach((ref WaterwayComposition wc) =>
        {
            // read speed limit
            float currentLimit = wc.m_SpeedLimit;
            // adjust if needed
            wc.m_SpeedLimit = currentLimit + 1f;
        }).Schedule();
    }
}