Skip to content

Game.TrainFlags

Assembly:
Assembly: Game / Assembly-CSharp (exact DLL not specified; typical Unity game assembly)

Namespace:
Game.Vehicles

Type:
public enum TrainFlags : uint

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

Summary:
Flags enum representing per-train boolean state bits used by the game. Each named value is a single bit (or bit mask) which can be combined using bitwise operations. Common uses: track whether a train is reversed, where passengers board (left/right), whether it has a pantograph deployed, and whether parked vehicles should be ignored for certain logic.


Fields

  • Reversed = 1u
    Bit flag indicating the train is reversed (driving/registered direction is flipped). Value: 0x1 (1).

  • BoardingLeft = 2u
    Bit flag indicating boarding occurs on the left side of the train. Value: 0x2 (2).

  • BoardingRight = 4u
    Bit flag indicating boarding occurs on the right side of the train. Value: 0x4 (4).

  • Pantograph = 8u
    Bit flag indicating the train's pantograph is present/deployed (relevant for electric trains). Value: 0x8 (8).

  • IgnoreParkedVehicle = 0x10u
    Bit flag instructing certain logic to ignore parked vehicles when considering this train (Value: 0x10 / 16).

Properties

  • None — this is a simple flags enum; it does not define properties.
    Note: enum variables default to 0 (no flags set) if not initialized.

Constructors

  • None — enums do not have user-defined constructors. Values are the named constants listed above. The default underlying numeric value for an uninitialized enum variable is 0.

Methods

  • None defined on this enum.
    (If needed, use bitwise operators or helpers like Enum.HasFlag to work with values.)

Usage Example

// Combine flags
TrainFlags flags = TrainFlags.Reversed | TrainFlags.Pantograph;

// Check a flag (fast bitwise way)
bool isReversed = (flags & TrainFlags.Reversed) != 0;

// Check with Enum.HasFlag (slower but clearer)
bool hasPantograph = flags.HasFlag(TrainFlags.Pantograph);

// Set a flag
flags |= TrainFlags.BoardingRight;

// Clear a flag
flags &= ~TrainFlags.Reversed;

// Toggle a flag
flags ^= TrainFlags.IgnoreParkedVehicle;

// Example: decide boarding side
if ((flags & TrainFlags.BoardingLeft) != 0) {
    // handle left-side boarding
} else if ((flags & TrainFlags.BoardingRight) != 0) {
    // handle right-side boarding
} else {
    // default boarding behavior
}

Additional notes: - Because the enum is marked with [Flags], ToString() will produce a combined name like "Reversed, Pantograph" for combined values. - When interoperating with low-level code or storage, you can cast to/from the underlying uint: uint raw = (uint)flags; flags = (TrainFlags)raw;