Game.Assets.MapMetadata
Assembly: Game
Namespace: Game.Assets
Type: class
Base: Metadata
Summary:
MapMetadata is a concrete Metadata
Fields
-
public const string kExtension = ".MapMetadata"
Used as the file extension for serialized map metadata assets. Use this constant when constructing or filtering filenames for map metadata resources. -
public static readonly Func<string> kPersistentLocation = () => "Maps/" + PlatformManager.instance.userSpecificPath
A function that returns the persistent path (relative to the user's data area) where map metadata is stored. Note that this accesses PlatformManager.instance; callers should ensure PlatformManager is initialized before invoking the delegate to avoid a NullReferenceException.
Properties
- (none declared in this class)
This class inherits members from Metadata. The most relevant inherited members used here are: id, identifier, state, database, target, and GetMeta(). Consult Metadata for inherited properties and lifecycle behavior.
Constructors
public MapMetadata()
No explicit constructor is declared; the default public parameterless constructor is provided by the compiler. Initialization logic is expected to occur via the lifecycle methods inherited from Metadata(e.g., OnPostLoad).
Methods
protected override void OnPostLoad()
This override runs after the metadata has been loaded. Behavior:- Executes only when state == LoadState.Full and when the backing database contains the metadata id (base.database.dataSource.Contains(base.id)).
- Sets base.target.id to base.identifier to ensure the MapInfo target has a proper id.
- Retrieves source metadata via GetMeta() (returns a SourceMeta).
- Assigns this MapMetadata instance to base.target.metaData.
- Sets base.target.isReadonly to the inverse of meta.belongsToCurrentUser (i.e., readonly if the source meta does not belong to the current user).
- Sets base.target.cloudTarget to meta.remoteStorageSourceName (the remote/cloud storage identifier). If the preconditions are not met, the method leaves the target unmodified.
Usage Example
// Getting the storage path for map metadata files:
string persistentPath = Game.Assets.MapMetadata.kPersistentLocation(); // e.g. "Maps/<userSpecificPath>"
// Using the extension when building a filename:
string filename = "MyCustomMap" + Game.Assets.MapMetadata.kExtension; // "MyCustomMap.MapMetadata"
// Note: MapMetadata instances are managed by the asset/metadata system.
// The OnPostLoad override is invoked by that system when the metadata is fully loaded.
// Typical usage is to query the asset/metadata database rather than instantiating MapMetadata manually.
Additional notes:
- MapMetadata depends on Colossal.PSI.Common.SourceMeta for ownership and remote storage data; behavior may vary depending on remote storage and user ownership.
- Ensure PlatformManager.instance is available before calling kPersistentLocation.
- This class assumes the underlying Metadata