Skip to content

Game.City.XPRewardFlags

Assembly:
Likely compiled into the game's assemblies (e.g., Assembly-CSharp / Game). Use the assembly your mod targets.

Namespace: Game.City

Type: enum (with [Flags] attribute)

Base: System.Enum (underlying type: byte)

Summary: XPRewardFlags is a byte-backed flags enum used to represent one or more XP-reward conditions in the game. Currently it defines a single flag, ElectricityGridBuilt, which likely indicates that the player has been awarded XP for building or completing an electricity grid-related objective. The [Flags] attribute allows combining multiple reward conditions in the future as bit flags.


Fields

  • ElectricityGridBuilt = 1
    Represents the flag for rewarding XP when an electricity grid is built/completed. As a flags enum, this value occupies the bit 0 (0x01). Additional reward flags (if added later) should use distinct bit values (2, 4, 8, ...).

Properties

  • None (this is a simple flags enum)

Constructors

  • None (enums do not define constructors)

Methods

  • None (standard enum methods apply, e.g., Enum.HasFlag, bitwise operators)

Usage Example

using Game.City;

public class XPHandler
{
    // Combine flags
    XPRewardFlags flags = XPRewardFlags.ElectricityGridBuilt;

    // Check a flag using bitwise operation
    bool hasElectricityXP = (flags & XPRewardFlags.ElectricityGridBuilt) != 0;

    // Or using Enum.HasFlag (boxing cost)
    bool hasElectricityXP2 = flags.HasFlag(XPRewardFlags.ElectricityGridBuilt);

    // Add another flag (example for future flags)
    // flags |= XPRewardFlags.AnotherReward; // where AnotherReward = 2

    // Clear a flag
    flags &= ~XPRewardFlags.ElectricityGridBuilt;
}

Notes and recommendations: - Because the enum is marked with [Flags] and uses byte as the underlying type, ensure any added flags use distinct single-bit values to avoid collisions (1, 2, 4, 8, ...). - Prefer bitwise checks for performance-critical code to avoid boxing from Enum.HasFlag. - When serializing or storing the enum value (e.g., in savegame or mod data), remember it's a byte-sized value; ensure compatibility if new flags are added in later game versions.