Skip to content

Game.GameMode

Assembly: Assembly-CSharp
Namespace: Game

Type: enum

Base: System.Enum

Summary:
A bitflag enumeration used to represent the current high-level mode/state of the game (for example: playing the game, in the editor, at the main menu, etc.). Marked with [Flags], so values can be combined using bitwise operations. This enum is useful for modders to test or store what mode(s) the game is currently in, and to write logic that runs only in specific modes (or combinations of modes).


Fields

  • None = 0
    Represents no mode / undefined. Useful as an initial/default value or to explicitly clear flags.

  • Other = 1
    A generic "other" category for modes not explicitly listed. Use when the mode doesn't match Game, Editor, or MainMenu.

  • Game = 2
    Represents the normal gameplay mode (city simulation running, player in-game).

  • Editor = 4
    Represents editor mode (map/asset/scenario editors or other editing tools).

  • MainMenu = 8
    Represents the main menu/front-end of the game.

  • GameOrEditor = 6
    A convenience combination equal to Game | Editor (2 | 4 == 6). Use when you want to target both gameplay and editor contexts.

  • All = 0xF
    All known mode flags combined (bitmask for None/Other/Game/Editor/MainMenu as defined here). Typically equals 15. Use with caution: including None in an "all" mask may be semantically redundant, but this value provides a single constant representing every defined bit.

Properties

  • This enum type has no properties.
    As an enum, it exposes its named constants and can be used with standard enum/bitwise operations. For runtime checks you can use Enum.HasFlag, bitwise operators (&, |, ^), or equality comparisons.

Constructors

  • Enums do not define custom constructors in C#.
    You can cast integer values to GameMode (e.g., (GameMode)3) to create combined/explicit values, but there are no instance constructors to call.

Methods

  • This enum defines no methods.
    To work with values, use C# built-in enum utilities:
  • mode.HasFlag(GameMode.Game)
  • (mode & GameMode.Editor) != 0
  • (GameMode.Game | GameMode.Editor)

Usage Example

// Set current mode to Game
GameMode mode = GameMode.Game;

// Combine flags (add Editor)
mode |= GameMode.Editor; // now contains both Game and Editor (equivalent to GameOrEditor)

// Check if Game flag is present
if ((mode & GameMode.Game) != 0)
{
    // running in gameplay context
}

// Using HasFlag (note: slightly slower than bitwise ops)
if (mode.HasFlag(GameMode.Editor))
{
    // running in editor context
}

// Check for either Game or Editor using the provided convenience constant
if ((mode & GameMode.GameOrEditor) != 0)
{
    // handle logic common to both Game and Editor
}

// Set to MainMenu explicitly
mode = GameMode.MainMenu;

// Compare for exact match
if (mode == GameMode.MainMenu)
{
    // in main menu
}

Additional notes for modders: - Prefer bitwise checks ((mode & GameMode.X) != 0) for performance-critical code, or when testing for presence of one flag among many. - Use the predefined combination constants (GameOrEditor, All) to simplify code that should apply to multiple modes. - Be cautious when casting integers to this enum—ensure the numeric value maps to intended flags to avoid accidental states.