Skip to content

Game.Common.RaycastFlags

Assembly: Assembly-CSharp
Namespace: Game.Common

Type: public enum

Base: System.Enum (underlying type: System.UInt32)

Summary: RaycastFlags is a bitmask enum used to control what categories of objects are considered or ignored when performing raycasts in the game (selection, tool hits, editor queries, etc.). The Flags attribute allows combining multiple values with bitwise operations so callers can include or exclude specific sets of scene elements when performing ray intersection tests. Typical uses include filtering out UI/debug/tool objects, including sub-elements or decals, or toggling handling of outside connections and building lots for various editor/tool behaviors.


Fields

  • DebugDisable = 1u Exclude debug objects and gizmos from raycasts (ignore debug-only visuals).

  • UIDisable = 2u Ignore UI elements so on-screen UI won't block or be hit by the raycast.

  • ToolDisable = 4u Ignore tool-related objects (tools and their temporary geometry) during ray tests.

  • FreeCameraDisable = 8u Exclude objects related to the free camera mode (used when free camera is active).

  • ElevateOffset = 0x10u Apply an elevation offset in ray tests — typically used to handle elevated structures or offset snapping.

  • SubElements = 0x20u Include or consider sub-elements (for example lanes, sub-nodes, or smaller parts of a larger object).

  • Placeholders = 0x40u Include placeholder objects (temporary/ghost placements) in ray intersection results.

  • Markers = 0x80u Include marker objects (map markers, placement markers) in raycasts.

  • NoMainElements = 0x100u Exclude main elements, meaning only secondary/sub elements are considered.

  • UpgradeIsMain = 0x200u Treat upgrade elements as main elements for the purposes of the raycast.

  • OutsideConnections = 0x400u Include outside-connection objects (connections to external maps or modules).

  • Outside = 0x800u Include outside-level objects/entities in ray tests.

  • Cargo = 0x1000u Include cargo-related objects/entities in the raycast.

  • Passenger = 0x2000u Include passenger-related objects/entities in the raycast.

  • Decals = 0x4000u Include decals (surface textures, road markings, etc.) in ray intersection tests.

  • EditorContainers = 0x8000u Include editor-specific containers (used in map/asset editors) during raycasts.

  • SubBuildings = 0x10000u Include sub-buildings or attached building parts in ray tests.

  • PartialSurface = 0x20000u Consider partial surfaces (non-full-solid surfaces) when performing raycasts.

  • BuildingLots = 0x40000u Include building lot areas/markers in ray intersection results.

  • IgnoreSecondary = 0x80000u Ignore secondary elements (the inverse/compliment to flags that include secondaries).

Properties

  • None (enum type — use static values listed above).

Constructors

  • None (enum type — values are defined above).

Methods

  • None (enum type — no methods defined here).

Usage Example

// Combine flags with bitwise OR
RaycastFlags flags = RaycastFlags.SubElements | RaycastFlags.Decals | RaycastFlags.Placeholders;

// Check whether a particular flag is set (bitwise check is preferred for performance)
bool includeDecals = (flags & RaycastFlags.Decals) != 0;

// Clear a flag
flags &= ~RaycastFlags.Decals;

// Set a flag
flags |= RaycastFlags.Decals;

// Alternative (clearer but slightly slower): using Enum.HasFlag
bool hasDecals = flags.HasFlag(RaycastFlags.Decals);

// Example hypothetical raycast call (actual API may differ)
RaycastFlags query = RaycastFlags.SubElements | RaycastFlags.SubBuildings;
RaycastHit hit;
bool result = RaycastManager.Raycast(cameraRay, out hit, query); // pseudo-API: pass flags to raycast

// Use cases:
// - Exclude UI/debug: RaycastFlags.UIDisable | RaycastFlags.DebugDisable
// - Editor selection: include Placeholders, EditorContainers, BuildingLots, SubElements

Notes: - Because this is a [Flags] enum, values are bit flags (powers of two) and should be combined with bitwise operators. - For performance-sensitive code (e.g., per-frame raycasts), prefer bitwise (&) checks over Enum.HasFlag.