Description
The Metadata
property is a general-purpose key-value store used to modify the functionality of the user interface, map compilation, editor helpers, and more. It allows for dynamic customization and extension of the MapClass
behavior by storing additional data that can be accessed and manipulated at runtime.
Usage
Use the Metadata
property to store and retrieve custom data associated with a MapClass
instance. This can be useful for adding additional properties or settings that are not explicitly defined in the class structure.
To add a new metadata entry, simply assign a value to a key in the dictionary:
mapClassInstance.Metadata["CustomKey"] = "CustomValue";
To retrieve a value, access the dictionary with the corresponding key:
var value = mapClassInstance.Metadata["CustomKey"];
Example
// Example of using the Metadata property
var mapClassInstance = new Editor.MapClass();
// Adding metadata
mapClassInstance.Metadata["SpawnRate"] = 5;
mapClassInstance.Metadata["IsVisible"] = true;
// Retrieving metadata
int spawnRate = (int)mapClassInstance.Metadata["SpawnRate"];
bool isVisible = (bool)mapClassInstance.Metadata["IsVisible"];
// Checking if a key exists
if (mapClassInstance.Metadata.ContainsKey("SpawnRate"))
{
// Do something with the spawn rate
}