Game.TrafficLightState
Assembly:
Most likely the game's runtime assembly (e.g., Assembly-CSharp / Game). If you need the exact assembly for reflection or tooling, check your build output or the game's managed assemblies.
Namespace:
Game.Objects
Type:
public enum TrafficLightState : ushort
Base:
System.Enum (underlying type: System.UInt16 / ushort)
Summary:
A bitwise (Flags) enum representing possible states of a traffic light. The Flags attribute allows combining multiple states into a single value (for example: Flashing combined with Red). Typical usage is to store and test the state(s) of a traffic light in code for mod logic, AI, rendering, or traffic control.
Fields
-
None = 0
Represents no state. Use as a default or cleared value. -
Red = 1
The traffic light is showing red. -
Yellow = 2
The traffic light is showing yellow (amber). -
Green = 4
The traffic light is showing green. -
Flashing = 8
The traffic light is in a flashing mode. Can be combined with other flags to indicate which color is flashing.
Properties
- (none)
This enum type has no properties. It is a plain bitwise enum used as a value type.
Constructors
- (none)
Enums do not define constructors. Values are created/assigned by casting or using the named members.
Methods
- (none)
The enum itself does not declare methods. Use standard Enum utilities (Enum.HasFlag, bitwise operators, or casting) to work with values.
Usage Example
// Combine flags
TrafficLightState state = TrafficLightState.Red | TrafficLightState.Flashing;
// Check a flag
bool isFlashing = state.HasFlag(TrafficLightState.Flashing);
// Using bitwise operators (faster than HasFlag for simple checks)
bool isRed = (state & TrafficLightState.Red) != 0;
// Set a flag
state |= TrafficLightState.Yellow;
// Clear a flag
state &= ~TrafficLightState.Flashing;
// Toggle a flag
state ^= TrafficLightState.Green;
// Example function interpreting states
string Describe(TrafficLightState s)
{
if (s == TrafficLightState.None) return "No signal";
var parts = new System.Collections.Generic.List<string>();
if ((s & TrafficLightState.Red) != 0) parts.Add("Red");
if ((s & TrafficLightState.Yellow) != 0) parts.Add("Yellow");
if ((s & TrafficLightState.Green) != 0) parts.Add("Green");
if ((s & TrafficLightState.Flashing) != 0) parts.Add("Flashing");
return string.Join(" | ", parts);
}
Notes and tips: - Because this enum uses the [Flags] attribute, prefer bitwise operations for performance-sensitive code in hot loops (e.g., traffic simulations). - When serializing or storing state, use the underlying numeric value (ushort) if you need compact representations. - Be cautious combining mutually exclusive colors (Red/Yellow/Green) unless your game logic explicitly allows composite meanings (e.g., Yellow+Flashing).