Game.Prefabs.RoadFlags
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: public enum (with [Flags])
Base: System.Enum (underlying type: System.Int32)
Summary:
RoadFlags is a bitmask enum used to describe configurable properties/behaviors of road prefabs. The [Flags] attribute indicates values can be combined using bitwise operations. Common uses include toggling features such as zoning, separated carriageways, traffic light preference, default orientation and street lights for a road prefab in Cities: Skylines 2 modding. Each member represents a single bit so multiple flags can be stored in a single integer-sized field.
Fields
-
EnableZoning = 1
Enables zoning on the road (allows placing zoned buildings adjacent to the road). -
SeparatedCarriageways = 2
Indicates the road has physically separated carriageways (two distinct directions that may affect vehicle routing and lane behaviour). -
PreferTrafficLights = 4
Marks that the road prefers traffic lights at intersections rather than roundabouts or priority rules. -
DefaultIsForward = 8
Specifies that the default orientation of the road prefab is "forward" (used when placing the road to determine lane directions, signage, etc.). -
UseHighwayRules = 0x10
(16)
Apply highway-specific rules (e.g., different vehicle restrictions, junction behaviour or speed limits). -
DefaultIsBackward = 0x20
(32)
Specifies that the default orientation of the road prefab is "backward". (Mutually exclusive with DefaultIsForward in intent — whichever is set indicates the default placement orientation.) -
HasStreetLights = 0x40
(64)
Indicates that the road prefab includes street lights (used for rendering and possibly gameplay effects like illumination).
Properties
- None (enum type; no custom properties defined).
Constructors
- None (enumerations do not declare constructors; underlying runtime provides default value and conversion methods).
Methods
- None defined on this type. Use standard System.Enum and integer/bitwise operations to manipulate values (e.g., HasFlag, bitwise &, |, ^, ~). Example helpers:
- RoadFlags.HasFlag(RoadFlags.EnableZoning)
- (flags & RoadFlags.HasStreetLights) != 0
Usage Example
// Combine flags when creating/setting a road prefab property:
RoadFlags flags = RoadFlags.EnableZoning | RoadFlags.HasStreetLights | RoadFlags.PreferTrafficLights;
// Check for a flag:
bool canZone = (flags & RoadFlags.EnableZoning) != 0;
// or using Enum.HasFlag (slower boxing):
bool hasLights = flags.HasFlag(RoadFlags.HasStreetLights);
// Add a flag:
flags |= RoadFlags.SeparatedCarriageways;
// Remove a flag:
flags &= ~RoadFlags.PreferTrafficLights;
// Toggle a flag:
flags ^= RoadFlags.UseHighwayRules;
// Convert to integer (storage/serialization/debugging):
int raw = (int)flags;
// Parse from string:
if (Enum.TryParse<RoadFlags>("EnableZoning,HasStreetLights", out var parsed))
{
// use parsed
}
Notes and tips: - Because this is a [Flags] enum, use bitwise operators for performance-critical code rather than HasFlag(), which boxes the enum. - Be mindful of DefaultIsForward vs DefaultIsBackward; they are intended to describe default orientation and are typically mutually exclusive for a single prefab. - When extending or mapping these flags across save files or network code, store the underlying integer value to preserve combined flags.