Skip to content

Game.UI.InGame.CitizenHappinessKey

Assembly: Assembly-CSharp (Cities: Skylines 2)
Namespace: Game.UI.InGame

Type: enum

Base: System.Enum

Summary:
Represents discrete happiness states used by the UI (and gameplay systems) to describe a citizen's emotional state. Typically used for mapping to icons, colors, tooltips or gameplay thresholds. Values are assigned in ascending order starting at 0 (Depressed = 0, ... Happy = 4).


Fields

  • Depressed
    Represents the lowest happiness state. Integer value: 0. Often shown with a negative/alert icon and red coloring.

  • Sad
    Represents a below-neutral happiness state. Integer value: 1. Used for mildly negative sentiments.

  • Neutral
    Represents a neutral or indifferent happiness state. Integer value: 2. No bonuses or penalties typically applied.

  • Content
    Represents a positive, satisfied happiness state. Integer value: 3. Shown with positive iconography (e.g., green/pleasant).

  • Happy
    Represents the highest happiness state. Integer value: 4. Often grants positive UI feedback and may influence game mechanics positively.

Properties

  • None declared.
    (Inherits any enum-related behavior from System.Enum; there are no custom properties on this type.)

Constructors

  • None declared.
    (Enums have an implicit underlying value constructor; individual values are the defined named constants.)

Methods

  • None declared on the enum itself.
    (Common helper methods are available via System.Enum / System.Object, for example: ToString(), GetValues(typeof(CitizenHappinessKey)), Enum.Parse/TryParse, and GetName/GetNames.)

Usage Example

// Map enum to UI assets (icons/colors) and display text
void UpdateCitizenHappinessUI(CitizenHappinessKey key)
{
    // Example arrays indexed by enum underlying value
    Sprite[] happinessIcons = /* loaded sprites: Depressed..Happy */;
    Color[] happinessColors = /* colors matching each state */;

    // Convert enum to index
    int index = (int)key;

    // Set UI elements
    happinessIconImage.sprite = happinessIcons[index];
    happinessIconImage.color = happinessColors[index];
    happinessLabel.text = Localization.Get($"HAPPINESS_{key}"); // e.g. "HAPPINESS_Happy"

    // Example switch for behavior
    switch (key)
    {
        case CitizenHappinessKey.Depressed:
            // apply negative UI/logic
            break;
        case CitizenHappinessKey.Happy:
            // apply positive UI/logic
            break;
    }
}

{{ Additional notes: When integrating with save/serialization or external data, store the underlying integer or the enum name. If you add new enum values, ensure UI mappings (arrays, switch statements, serialization) are updated accordingly to avoid index mismatches. }}