Skip to content

Game.Net.TrafficLightFlags

Assembly: Game (assembly name not specified in source)
Namespace: Game.Net

Type: public enum (with [Flags] attribute)

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

Summary: A set of bit flags describing special properties of a traffic-light node in the networking/game code. The enum is marked with [Flags] so individual values can be combined with bitwise operations. The underlying storage is a single byte, so values must be distinct powers of two and fit within 8 bits.


Fields

  • LevelCrossing = 1 Indicates the traffic light/node is associated with a level crossing (rail crossing). Value: 0x01.

  • MoveableBridge = 2 Indicates the traffic light/node is associated with a movable bridge. Value: 0x02.

  • IsSubNode = 4 Indicates the traffic light/node is a sub-node (a secondary/auxiliary node). Value: 0x04.

Properties

  • None. This enum type does not declare properties. Use bitwise operations or Enum.HasFlag to inspect flag values at runtime.

Constructors

  • public TrafficLightFlags() Enums do not have user-defined constructors. The default value for an enum variable is the numeric zero (no flags set). Note: this enum does not define a named member with value 0 (e.g., None), so a default-initialized variable will be 0 but not equal to any named enum member.

Methods

  • None declared on this enum. Use standard enum/bitwise operations and System.Enum helpers:
  • ((flags & TrafficLightFlags.MoveableBridge) != 0) to test a flag
  • flags.HasFlag(TrafficLightFlags.LevelCrossing) as a convenience (slower)
  • flags |= TrafficLightFlags.IsSubNode to set a flag
  • flags &= ~TrafficLightFlags.IsSubNode to clear a flag
  • (byte)flags to obtain the underlying byte for serialization/networking
  • (TrafficLightFlags)someByte to reconstruct from a received byte

Usage Example

// Combine flags
TrafficLightFlags flags = TrafficLightFlags.LevelCrossing | TrafficLightFlags.IsSubNode;

// Test flags (bitwise)
if ((flags & TrafficLightFlags.MoveableBridge) != 0)
{
    // handle movable bridge behavior
}

// Test flags (Enum helper)
bool isLevelCrossing = flags.HasFlag(TrafficLightFlags.LevelCrossing);

// Set a flag
flags |= TrafficLightFlags.MoveableBridge;

// Clear a flag
flags &= ~TrafficLightFlags.IsSubNode;

// Serialize to network / save as byte
byte data = (byte)flags;

// Deserialize from network / load
TrafficLightFlags deserialized = (TrafficLightFlags)data;

{{ Additional notes for modders: - Because the enum uses an underlying byte, any new flag added in future must use a unique power-of-two value fitting within 8 bits (1,2,4,8,16,32,64,128). If you control shared code across mods, consider defining and documenting any extension flags to avoid collisions. - Consider adding an explicit None = 0 member if you need to express "no flags" semantically in your own code. - Prefer bitwise checks ((flags & X) != 0) in performance-sensitive paths; Enum.HasFlag uses reflection and is slower. - When working with networking/serialization (namespace Game.Net suggests network usage), be explicit about endianness/packing and send the byte form (cast to/from byte) to keep payloads small. }}