Skip to content

Game.Areas.MapFeature

Assembly: Assembly-CSharp (game runtime assembly; common for Cities: Skylines 2 mods)
Namespace: Game.Areas

Type: enum

Base: System.Enum (underlying type: System.Int32)

Summary: Represents discrete map feature types used by the game to classify tiles/areas (for gameplay systems such as terrain, resources, water, and buildability). The enum values are used as identifiers in map data structures and logic. The final member Count is a sentinel value representing the number of defined features.


Fields

  • None = -1 Represents the absence of any feature. Often used as a default/uninitialized value.

  • Area Generic area marker. Used for marking arbitrary areas (value 0).

  • BuildableLand Indicates land that can be built on (value 1).

  • FertileLand Marks land suitable for farming or otherwise fertile (value 2).

  • Forest Represents forested tiles/areas (value 3).

  • Oil Indicates presence of oil resources (value 4).

  • Ore Indicates presence of ore/mineral resources (value 5).

  • SurfaceWater Represents surface water (rivers, lakes) (value 6).

  • GroundWater Represents subsurface/groundwater (value 7).

  • Fish Indicates fish resources (value 8).

  • Count Sentinel value equal to the number of feature entries (value 9). Useful for iteration limits, bounds checking, or allocating arrays sized to the number of features.

Properties

  • No properties.
    Enums do not define instance properties; they expose named constant values. You can, however, use standard Enum methods (Enum.GetValues, Enum.IsDefined, etc.) to inspect values.

Constructors

  • No explicit constructors.
    Enum types do not declare constructors in user code; underlying integral values are assigned to each named member by the compiler.

Methods

  • No custom methods.
    Standard System.Enum/ValueType/Object methods are available (ToString, CompareTo, GetHashCode, etc.). Use Enum helper APIs for reflection-like operations (Enum.GetValues(typeof(MapFeature)), Enum.TryParse, etc.).

Usage Example

// Check a tile's feature
MapFeature feature = MapFeature.Forest;
if (feature == MapFeature.Forest)
{
    // apply forest-specific logic
}

// Iterate over all defined features (excluding None and/or Count if desired)
foreach (MapFeature f in Enum.GetValues(typeof(MapFeature)))
{
    if (f == MapFeature.None || f == MapFeature.Count) continue;
    // process feature f
}

// Safe cast from int (e.g., data from map arrays)
int raw = 4; // example
if (Enum.IsDefined(typeof(MapFeature), raw))
{
    MapFeature mf = (MapFeature)raw;
    // use mf
}

// Using Count to size an array
int featureCount = (int)MapFeature.Count; // 9 in current enum
int[] featureCounters = new int[featureCount];

Additional notes: - Treat MapFeature.Count as a non-feature sentinel (do not treat it as a valid map feature). - The underlying integer values start at 0 (except None = -1); if you rely on numeric values, ensure they are stable across game versions or perform checks using Enum.IsDefined.