Skip to content

Game.RaycastInput

Assembly: Assembly-CSharp
Namespace: Game.Common

Type: struct

Base: System.ValueType

Summary:
Represents input data for performing raycasts in the game (Cities: Skylines 2). Encapsulates the ray segment, offsets and a collection of bitmask/enum fields that filter or modify the raycast (what types to hit, collision masks, layers, area/route/transport/utility filters, and control flags). Use this struct to specify what the raycast should consider and to quickly check whether the raycast is currently disabled by any UI/tool/debug flags.


Fields

  • public Line3.Segment m_Line
    Defines the ray as a line segment in 3D space (start/end). This is the primary geometric input for the raycast.

  • public float3 m_Offset
    A positional offset applied to the ray (relative displacement), typically used to shift the ray start/end in local or world coordinates.

  • public TypeMask m_TypeMask
    Bitmask specifying which in-game object/entity types the raycast should consider (e.g., buildings, props, vehicles). Controls type-level filtering.

  • public RaycastFlags m_Flags
    Flags that change raycast behavior or indicate why it may be disabled. Common flags include DebugDisable, UIDisable, ToolDisable, FreeCameraDisable (these are checked by IsDisabled()).

  • public CollisionMask m_CollisionMask
    Mask that specifies which collision layers or types should be checked during the raycast (physics/collision-level filtering).

  • public Layer m_NetLayerMask
    Layer mask specifically for network/segment layers (roads, tracks, etc.), influencing whether nets are considered by the raycast.

  • public AreaTypeMask m_AreaTypeMask
    Bitmask specifying which area types (zoning or area classifications) the raycast is allowed to interact with or consider.

  • public RouteType m_RouteType
    Specifies the route type to filter route-related raycasts (e.g., pedestrian, vehicle, freight route types).

  • public TransportType m_TransportType
    Specifies a transport type filter for raycasts that target transport-specific elements (buses, trains, metros, etc.).

  • public IconLayerMask m_IconLayerMask
    Mask to filter icon layers (UI/overlay icons) that the raycast should hit or ignore.

  • public UtilityTypes m_UtilityTypeMask
    Mask specifying utility types to include/exclude (e.g., water, electricity, sewage) for utility-related raycasting.

Properties

  • None (this struct exposes only public fields and instance methods; there are no C# properties defined).

Constructors

  • public RaycastInput()
    Implicit default struct constructor. All fields are default-initialized (numeric values to 0, enums to their default, masks cleared). Populate fields explicitly before issuing a raycast.

Methods

  • public bool IsDisabled() : System.Boolean
    Checks whether the raycast is currently disabled by any of the disabling flags. Returns true if any of the following flags are set on m_Flags: RaycastFlags.DebugDisable, RaycastFlags.UIDisable, RaycastFlags.ToolDisable, RaycastFlags.FreeCameraDisable. Use this to early-out and avoid performing raycasts when they should be suppressed.

Implementation summary: - Performs a bitwise AND between m_Flags and the combined disabling flags and returns whether the result is non-zero.

Usage Example

// Construct a raycast input and check if it's allowed to run
var input = new Game.Common.RaycastInput
{
    m_Line = new Colossal.Mathematics.Line3.Segment(startPosition, endPosition),
    m_Offset = new Unity.Mathematics.float3(0f, 0.5f, 0f), // raise raycast slightly
    m_TypeMask = TypeMask.Buildings | TypeMask.Props,
    m_Flags = RaycastFlags.None,
    m_CollisionMask = CollisionMask.Default,
    m_NetLayerMask = Layer.Road,
    m_AreaTypeMask = AreaTypeMask.None,
    m_RouteType = RouteType.Vehicle,
    m_TransportType = TransportType.Bus,
    m_IconLayerMask = IconLayerMask.None,
    m_UtilityTypeMask = UtilityTypes.Electricity
};

// Skip performing the raycast if disabled by flags
if (!input.IsDisabled())
{
    // perform the raycast with Game's raycast system using `input`
}

Notes: - Many of the mask/enum types used here (TypeMask, RaycastFlags, CollisionMask, Layer, AreaTypeMask, RouteType, TransportType, IconLayerMask, UtilityTypes) are bitmasks/enums defined elsewhere in the game's codebase; consult their definitions to compose correct mask values. - IsDisabled focuses solely on the flags that indicate global/tool/UI/debug disabling; other fields must be validated separately as needed.