Description
The SetKeyValue
method is used to assign a value to a specific key within a MapEntity
. This method updates the key/value pairs that define the state of the entity in the Hammer editor. It is essential for modifying the properties of an entity programmatically.
Usage
To use the SetKeyValue
method, you need to provide a key and a value, both as strings. The key represents the property name you want to set, and the value is the new value for that property.
Ensure that the key you provide is valid for the entity type you are working with, as invalid keys may not have any effect or could lead to unexpected behavior.
Example
// Example of using SetKeyValue
MapEntity entity = new MapEntity();
entity.SetKeyValue("health", "100");
entity.SetKeyValue("model", "models/props_c17/oildrum001.mdl");
// This sets the 'health' key to '100' and the 'model' key to the specified model path.