Game.Prefabs.TrafficLightType
Assembly: Assembly-CSharp.dll (game assembly)
Namespace: Game.Prefabs
Type: public enum TrafficLightType
Base: System.Enum (underlying type: System.Int32)
Summary:
Flags enum that describes allowed movement types and behavior modifiers for traffic lights/pedestrian crossings. The enum values are bit flags so multiple options can be combined using bitwise operations. The values indicate vehicle turn permissions, pedestrian crossing directions, and whether the light may be used in a flipped (mirrored) orientation.
Fields
-
VehicleLeft = 1
Allows vehicles to turn left through the traffic light. -
VehicleRight = 2
Allows vehicles to turn right through the traffic light. -
CrossingLeft = 4
Allows pedestrian crossing on the left side (or a left-side crossing phase). -
CrossingRight = 8
Allows pedestrian crossing on the right side (or a right-side crossing phase). -
AllowFlipped = 0x10
(Decimal 16) Indicates the traffic light may be flipped/mirrored (e.g., for lane orientation differences). This is a modifier flag rather than a direct movement permission.
Properties
- None defined on the enum type itself. Use standard System.Enum members and extension/utility methods in code if needed.
Constructors
- Enums do not declare explicit constructors. The underlying storage is Int32 and the default value (0) is a valid integer but not named by this enum. Use explicit casting to/from integer values if required:
- Example:
TrafficLightType t = (TrafficLightType)0;
orTrafficLightType t = TrafficLightType.VehicleLeft;
Methods
- No instance methods are defined on this enum. Use standard Enum/System methods and bitwise operations:
HasFlag
(e.g.,flags.HasFlag(TrafficLightType.VehicleLeft)
)- Bitwise operators:
|
(combine),&
(test/mask),~
(invert),^
(toggle) - The
[Flags]
attribute indicates values are intended to be combined; code should treat enum values as bit flags.
Usage Example
// Combine vehicle left and right permissions
TrafficLightType vehicleTurns = TrafficLightType.VehicleLeft | TrafficLightType.VehicleRight;
// Add AllowFlipped modifier
vehicleTurns |= TrafficLightType.AllowFlipped;
// Check for a specific flag
bool allowsLeft = vehicleTurns.HasFlag(TrafficLightType.VehicleLeft);
// Remove a flag (e.g., disallow right turns)
vehicleTurns &= ~TrafficLightType.VehicleRight;
// Example: set pedestrian crossings on both sides
TrafficLightType crossings = TrafficLightType.CrossingLeft | TrafficLightType.CrossingRight;
// Casting from/to int
int rawValue = (int)vehicleTurns;
TrafficLightType fromInt = (TrafficLightType)rawValue;