# Runtime Modification

You can of course modify maps at runtime. Here's a simple example code which will add new cells to a layer and execute a build process.

Please have a look at following samples for a more advanced approach:

* Deep Rock Crystals URP
* Runtime Editor URP

Refer to the API documentation for more:

{% content-ref url="/pages/gsawsVs4esfRNbceeHID" %}
[API](/tileworldcreator-v4-documentation/api.md)
{% endcontent-ref %}

## Namespace

```csharp
using GiantGrey.TileWorldCreator;
```

## Add & Remove Cells at runtime

```csharp
public TileWorldCreatorManager manager;

// Register to blueprint layers ready event
// So we can then execute the build layers.
void OnEnable()
{
    manager.OnBlueprintLayersReady += BuildMap;
}
		 
void OnDisable()
{
    manager.OnBlueprintLayersReady -= BuildMap;
}
		
		
public void AddCells()
{
    HashSet<Vector2> positions = new HashSet<Vector2>;
    
    // Add some positions
    positions.Add(new Vector2(0.0f, 1.0f));
    positions.Add(new Vector2(0.0f, 2.0f));
    positions.Add(new Vector2(1.0f, 1.0f));
    positions.Add(new Vector2(1.0f, 2.0f));
    
    // Add cells to a layer (MyLayer)
    manager.AddCellsToLayer("MyLayer", positions);
    
    // Remove cells from a layer (MyLayer)
    //manager.RemoveCellsFromLayer("MyLayer", positions);
    
    // Execute all blueprint layers
    manager.ExecuteBlueprintLayers();
}

// As soon as blueprint layers are ready, we call the ExecuteAllBuildLayers
void BuildMap()
{
    manager.ExecuteBuildLayers(ExecutionMode.Normal);
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://giantgrey.gitbook.io/tileworldcreator-v4-documentation/runtime-modification.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
