Skip to content

Game.Citizens.HouseholdFlags

Assembly: Assembly-CSharp
Namespace: Game.Citizens

Type: public enum (with [Flags] attribute)

Base: System.Enum (underlying type: byte)

Summary: HouseholdFlags is a bitflag enum used to mark attributes of a household in the Citizens system. Because it is marked with [Flags] and has an explicit underlying type of byte, individual flags can be combined with bitwise operations and stored/serialized efficiently as a single byte. Typical uses include marking a household as a tourist, commuter, or newly moved in.


Fields

  • None = 0
    Represents no flags set.

  • Tourist = 1
    Indicates the household is a tourist household. This flag can affect behavior such as tourism-related AI or service usage.

  • Commuter = 2
    Indicates the household contains commuters (citizens who travel to work outside the city or to other districts). Can be used by transport/commuting systems.

  • MovedIn = 4
    Indicates the household has recently moved in. Useful for one-time initialization behavior, notifications, or statistics.

Properties

  • None
    Enums do not declare instance properties. Use bitwise operations or helper methods to query/modify flags.

Constructors

  • None (default enum construction)
    As an enum, there are no custom constructors. The underlying storage type is byte; values can be cast to/from byte when storing or serializing.

Methods

  • None (no instance methods declared in this enum)
    Standard System.Enum/static helpers (e.g., Enum.ToString, Enum.HasFlag) are available, but no custom methods are defined here.

Usage Example

// Set flags
HouseholdFlags flags = HouseholdFlags.None;
flags |= HouseholdFlags.Tourist;
flags |= HouseholdFlags.MovedIn;

// Check flags (recommended: use bitwise check for performance in hot paths)
bool isTourist = (flags & HouseholdFlags.Tourist) != 0;
bool isMovedIn = (flags & HouseholdFlags.MovedIn) != 0;

// Clear a flag
flags &= ~HouseholdFlags.MovedIn;

// Toggle a flag
flags ^= HouseholdFlags.Commuter;

// Combine flags
HouseholdFlags combined = HouseholdFlags.Tourist | HouseholdFlags.Commuter;

// Serialize/deserialize to a byte
byte stored = (byte)flags;
HouseholdFlags loaded = (HouseholdFlags)stored;

// Note: Enum.HasFlag() is available but boxes the value and is slower:
if (flags.HasFlag(HouseholdFlags.Tourist)) { /* ... */ }

Extra notes: - Because this enum uses the [Flags] attribute, treat values as bitfields and combine them with bitwise operators. - Prefer (flags & Flag) != 0 over Enum.HasFlag in performance-sensitive code to avoid boxing. - Do not change numeric values of existing flags in future updates; changing values can break savegame/mod compatibility. If you need new flags, add values using new bit positions (e.g., 8, 16, ...).