Game.Assets.MapInfo
Assembly:
Namespace: Game.Assets
Type: class
Base: System.Object, IJsonWritable, IContentPrerequisite, System.IComparable
Summary:
Represents metadata and basic settings for a playable map in Cities: Skylines 2. MapInfo contains display and localization assets (thumbnail/preview/locale), geographic and climate parameters (latitude, longitude, temperatureRange, cloudiness, precipitation, climate prefab), gameplay-related metrics (area, buildableLand, water/groundwater availability, resources, connections), prerequisites for loading content, and runtime flags (locked, isReadonly). It implements IJsonWritable to serialize the map metadata to JSON and IComparable
Fields
N/A
This class does not declare private backing fields in the source; all stored values are exposed as auto-properties. Some properties are decorated with attributes such as [Exclude] and [DecodeAlias], which affect serialization/deserialization behavior.
Properties
-
public string id { get; set; }
Identifier for the map. Marked with [Exclude], meaning it is omitted from certain automatic serialization/deserialization flows; still written explicitly by the Write method. -
public string displayName { get; set; }
Human-readable name shown in UI when selecting the map. -
public TextureAsset thumbnail { get; set; }
Small image asset used as the map's thumbnail in menus. Write() will serialize this to a URI using MenuHelpers.defaultThumbnail as a fallback. -
public TextureAsset preview { get; set; }
Larger preview image asset shown in map selection UI. Write() will serialize this to a URI using MenuHelpers.defaultPreview as a fallback. -
public string theme { get; set; }
Semantic theme identifier or category for the map (e.g., climate/biome tag). -
public Bounds1 temperatureRange { get; set; }
Temperature bounds for the map climate (min/max). Uses the game's Bounds1 type. -
public float cloudiness { get; set; }
A float describing the average cloudiness parameter for the map. -
public float precipitation { get; set; }
A float for precipitation level (e.g., rainfall/snow likelihood). -
public float latitude { get; set; }
Geographic latitude used for environmental effects/lighting. -
public float longitude { get; set; }
Geographic longitude used for environmental effects/lighting. -
public float buildableLand { get; set; }
Proportion or absolute area of buildable land on the map. -
public float area { get; set; }
Total area of the map. -
public float surfaceWaterAvailability { get; set; }
Surface water availability value. Has [DecodeAlias(new string[] { "waterAvailability" })], so older JSON that uses "waterAvailability" will decode into this property. -
public float groundWaterAvailability { get; set; }
Subsurface/groundwater availability metric. -
public MapMetadataSystem.Resources resources { get; set; }
Resource definitions available on the map (e.g., ore, oil). Type is nested under MapMetadataSystem. -
public MapMetadataSystem.Connections connections { get; set; }
Connection info (predefined road/rail/sea/air links) for the map. Type is nested under MapMetadataSystem. -
public string[] contentPrerequisites { get; set; }
List of content prerequisite IDs required by this map. Has [DecodeAlias(new string[] { "contentPrerequisite" })] so older single-value names decode correctly. -
public bool nameAsCityName { get; set; }
If true, the map display name may be used as a starting city name. -
public int startingYear { get; set; } = -1
Starting in-game year for the map (default -1 when unspecified). -
public MapData mapData { get; set; }
Reference to the actual map data (heightmap, terrain layers, etc.). -
public MapMetadata metaData { get; set; }
Additional metadata container. Marked [Exclude] so it's not serialized by default Write flows; used internally. -
public Guid sessionGuid { get; set; }
Unique identifier for a map/session instance. -
public LocaleAsset[] localeAssets { get; set; }
Array of locale assets providing localized strings for the map UI. -
public PrefabAsset climate { get; set; }
Reference to a climate prefab asset that configures climate-related behavior for the map. -
public bool isReadonly { get; set; }
Marked [Exclude]; indicates the map is read-only (cannot be modified in-editor or saved over). -
public string cloudTarget { get; set; }
Marked [Exclude]; internal runtime target identifier for procedural cloud systems. -
public bool locked { get; set; }
Marked [Exclude]; indicates the map is locked (e.g., cannot be selected or modified) at runtime.
Constructors
public MapInfo()
Implicit default constructor. Initializes a new MapInfo instance; most properties are left at default CLR values (strings null, numeric 0, startingYear = -1 as declared).
Methods
-
public void Write(IJsonWriter writer)
Serializes the MapInfo instance to JSON using the provided IJsonWriter. The method writes the concrete type name then explicitly writes a selection of properties, including id, displayName, thumbnail/preview (as URIs with fallback defaults via MenuHelpers), theme, temperatureRange, cloudiness, precipitation, latitude, longitude, area, buildableLand, surfaceWaterAvailability, groundWaterAvailability, resources, connections, contentPrerequisites, locked, nameAsCityName, startingYear, isReadonly, and cloudTarget. Use this when exporting map metadata to JSON for save files or asset metadata. -
public int CompareTo(MapInfo other)
Implements IComparable. Orders MapInfo instances by id using a case-insensitive ordinal string comparison. Returns negative/zero/positive per standard CompareTo semantics. -
public MapInfo Copy()
Creates a shallow copy of this MapInfo. The copy duplicates property references (not deep clones): strings and structs are copied, but reference types (TextureAsset, MapData, resources, connections, localeAssets, etc.) are copied by reference. Useful when making a mod or runtime change based on an existing map without mutating the original instance.
Usage Example
// Create and populate a MapInfo
var map = new MapInfo
{
id = "island_01",
displayName = "Sunny Island",
thumbnail = someTextureAsset, // TextureAsset instance
preview = somePreviewAsset,
theme = "Temperate",
temperatureRange = new Bounds1(-10f, 35f),
cloudiness = 0.25f,
precipitation = 0.2f,
latitude = 34.0f,
longitude = -118.0f,
area = 1024f,
buildableLand = 600f,
surfaceWaterAvailability = 0.5f,
groundWaterAvailability = 0.3f,
contentPrerequisites = new[] { "core_assets", "beach_pack" },
startingYear = 2025,
localeAssets = new[] { localeAsset_en, localeAsset_sv }
};
// Write to JSON (IJsonWriter is part of the game's serialization system)
using (var writer = new GameJsonWriter(/* stream or context */))
{
map.Write(writer);
}
// Make a copy to modify without affecting the original
var copy = map.Copy();
copy.displayName = "Sunny Island (Edited)";
copy.locked = false;