import{_asa,cass,oase,Nasn}from"./chunks/framework.0799945b.js";constD=JSON.parse('{"title":"Dynamic Layers","description":"","frontmatter":{},"headers":[],"relativePath":"guide/advanced-concepts/dynamic-layers.md","lastUpdated":1682267650000}'),o={name:"guide/advanced-concepts/dynamic-layers.md"},l=n(`<h1 id="dynamic-layers" tabindex="-1">Dynamic Layers <a class="header-anchor" href="#dynamic-layers" aria-label="Permalink to "Dynamic Layers""></a></h1><p>You can dynamically add and remove layers using the <a href="/api/modules/game/layers#addlayer">addLayer</a> and <a href="/api/modules/game/layers#removelayer">removeLayer</a> functions. It's important to note that removing a layer does not affect the player's save data. You can safely add and remove the same layer without losing any progress. For instances where the structure of a layer changes, such as when adding a new feature, use the <a href="/api/modules/game/layers#reloadlayer">reloadLayer</a> function.</p><p>When procedurally generating layers with similar structures, consider using a utility function like the one below. This function allows you to access a correctly typed reference to a layer with a specified ID easily:</p><div class="language-ts"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#C792EA;">function</span><span style="color:#A6ACCD;"> </span><span style="color:#82AAFF;">getDynLayer</span><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;font-style:italic;">id</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">string</span><span style="color:#89DDFF;">):</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">DynamicLayer</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span></span>