> For the complete documentation index, see [llms.txt](https://giantgrey.gitbook.io/tileworldcreator-v4-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://giantgrey.gitbook.io/tileworldcreator-v4-documentation/runtime-modification.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
