Game.Prefabs.PolicePurpose
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: enum
Base: System.Enum (backed by System.Int32)
Summary:
PolicePurpose is a [Flags] enum used to describe one or more operational purposes for police-related prefabs/units in Cities: Skylines 2. Each named value represents a capability or task category (Patrol, Emergency response, Intelligence) and can be combined using bitwise operations to indicate that a unit or prefab serves multiple roles simultaneously.
Fields
-
Patrol = 1
Represents routine patrolling duties. Use this flag for units that regularly monitor areas, perform traffic/presence checks, or handle low-priority incidents. -
Emergency = 2
Represents emergency response capability. Use this flag for units that respond to high-priority incidents (fires, accidents, violent crimes) and require immediate dispatch. -
Intelligence = 4
Represents investigative or intelligence-related duties. Use this flag for units involved in investigations, surveillance, or data/analysis tasks.
Properties
None declared
Enums do not define instance properties in the source; use bitwise checks or System.Enum/System.Flags-related helpers to inspect values.
Constructors
None (enum values are created by the runtime)
Enums in C# don't have user-declared constructors. Values are represented by their underlying integral value (int by default).
Methods
None declared in this type
No custom methods are declared on this enum. Typical operations use standard enum/bitwise functionality:- Combine flags: PolicePurpose.Patrol | PolicePurpose.Intelligence
- Check flags: (purpose & PolicePurpose.Emergency) == PolicePurpose.Emergency or purpose.HasFlag(PolicePurpose.Emergency)
- Convert to/from numeric types via casts, or use Enum.Parse/Enum.TryParse for string conversions.
Usage Example
// Combine purposes: this police unit both patrols and performs intelligence work
PolicePurpose unitPurpose = PolicePurpose.Patrol | PolicePurpose.Intelligence;
// Check if the unit can handle emergencies
bool canHandleEmergency = unitPurpose.HasFlag(PolicePurpose.Emergency);
// Add Emergency role at runtime
unitPurpose |= PolicePurpose.Emergency;
// Remove Intelligence role
unitPurpose &= ~PolicePurpose.Intelligence;
// Example conditional behavior
if ((unitPurpose & PolicePurpose.Patrol) == PolicePurpose.Patrol)
{
// assign to patrol routes
}
Additional notes: - Because the enum is marked with [Flags], prefer bitwise operations and HasFlag for intent-expressive checks. - When serializing or storing enum values (e.g., in save data or prefab metadata), store the underlying integer to preserve combined flags reliably.