1 line
24 KiB
JavaScript
1 line
24 KiB
JavaScript
import{_ as e,c as t,o as a,N as r}from"./chunks/framework.0799945b.js";const u=JSON.parse('{"title":"Module: game/layers","description":"","frontmatter":{"editLink":false},"headers":[],"relativePath":"api/modules/game/layers.md","lastUpdated":null}'),o={name:"api/modules/game/layers.md"},d=r('<h1 id="module-game-layers" tabindex="-1">Module: game/layers <a class="header-anchor" href="#module-game-layers" aria-label="Permalink to "Module: game/layers""></a></h1><h2 id="interfaces" tabindex="-1">Interfaces <a class="header-anchor" href="#interfaces" aria-label="Permalink to "Interfaces""></a></h2><ul><li><a href="../../interfaces/game/layers.BaseLayer">BaseLayer</a></li><li><a href="../../interfaces/game/layers.FeatureNode">FeatureNode</a></li><li><a href="../../interfaces/game/layers.LayerEvents">LayerEvents</a></li><li><a href="../../interfaces/game/layers.LayerOptions">LayerOptions</a></li><li><a href="../../interfaces/game/layers.Position">Position</a></li></ul><h2 id="type-aliases" tabindex="-1">Type Aliases <a class="header-anchor" href="#type-aliases" aria-label="Permalink to "Type Aliases""></a></h2><h3 id="genericlayer" tabindex="-1">GenericLayer <a class="header-anchor" href="#genericlayer" aria-label="Permalink to "GenericLayer""></a></h3><p>Ƭ <strong>GenericLayer</strong>: <a href="./../features/feature#replace"><code>Replace</code></a><<a href="./layers#layer"><code>Layer</code></a><<a href="../../interfaces/game/layers.LayerOptions"><code>LayerOptions</code></a>>, { <code>minWidth</code>: <a href="./../util/computed#processedcomputable"><code>ProcessedComputable</code></a><<code>number</code>> ; <code>minimizable</code>: <a href="./../util/computed#processedcomputable"><code>ProcessedComputable</code></a><<code>boolean</code>> ; <code>name</code>: <a href="./../util/computed#processedcomputable"><code>ProcessedComputable</code></a><<code>string</code>> }></p><p>A type that matches any valid <a href="./layers#layer">Layer</a> object.</p><h4 id="defined-in" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in" aria-label="Permalink to "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/8c0a0c4/src/game/layers.tsx#L184" target="_blank" rel="noreferrer">profectus/src/game/layers.tsx:184</a></p><hr><h3 id="layer" tabindex="-1">Layer <a class="header-anchor" href="#layer" aria-label="Permalink to "Layer""></a></h3><p>Ƭ <strong>Layer</strong><<code>T</code>>: <a href="./../features/feature#replace"><code>Replace</code></a><<code>T</code> & <a href="../../interfaces/game/layers.BaseLayer"><code>BaseLayer</code></a>, { <code>classes</code>: <a href="./../util/computed#getcomputabletype"><code>GetComputableType</code></a><<code>T</code>[<code>"classes"</code>]> ; <code>color</code>: <a href="./../util/computed#getcomputabletype"><code>GetComputableType</code></a><<code>T</code>[<code>"color"</code>]> ; <code>display</code>: <a href="./../util/computed#getcomputabletype"><code>GetComputableType</code></a><<code>T</code>[<code>"display"</code>]> ; <code>forceHideGoBack</code>: <a href="./../util/computed#getcomputabletype"><code>GetComputableType</code></a><<code>T</code>[<code>"forceHideGoBack"</code>]> ; <code>minWidth</code>: <a href="./../util/computed#getcomputabletypewithdefault"><code>GetComputableTypeWithDefault</code></a><<code>T</code>[<code>"minWidth"</code>], <code>600</code>> ; <code>minimizable</code>: <a href="./../util/computed#getcomputabletypewithdefault"><code>GetComputableTypeWithDefault</code></a><<code>T</code>[<code>"minimizable"</code>], <code>true</code>> ; <code>minimizedDisplay</code>: <a href="./../util/computed#getcomputabletype"><code>GetComputableType</code></a><<code>T</code>[<code>"minimizedDisplay"</code>]> ; <code>name</code>: <a href="./../util/computed#getcomputabletypewithdefault"><code>GetComputableTypeWithDefault</code></a><<code>T</code>[<code>"name"</code>], <code>string</code>> ; <code>style</code>: <a href="./../util/computed#getcomputabletype"><code>GetComputableType</code></a><<code>T</code>[<code>"style"</code>]> }></p><p>An unit of game content. Displayed to the user as a tab or modal.</p><h4 id="type-parameters" tabindex="-1">Type parameters <a class="header-anchor" href="#type-parameters" aria-label="Permalink to "Type parameters""></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th></tr></thead><tbody><tr><td style="text-align:left;"><code>T</code></td><td style="text-align:left;">extends <a href="../../interfaces/game/layers.LayerOptions"><code>LayerOptions</code></a></td></tr></tbody></table><h4 id="defined-in-1" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-1" aria-label="Permalink to "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/8c0a0c4/src/game/layers.tsx#L168" target="_blank" rel="noreferrer">profectus/src/game/layers.tsx:168</a></p><h2 id="variables" tabindex="-1">Variables <a class="header-anchor" href="#variables" aria-label="Permalink to "Variables""></a></h2><h3 id="boundsinjectionkey" tabindex="-1">BoundsInjectionKey <a class="header-anchor" href="#boundsinjectionkey" aria-label="Permalink to "BoundsInjectionKey""></a></h3><p>• <code>Const</code> <strong>BoundsInjectionKey</strong>: <code>InjectionKey</code><<code>Ref</code><<a href="https://developer.mozilla.org/en-US/docs/Web/API/DOMRect" target="_blank" rel="noreferrer"><code>DOMRect</code></a> | <code>undefined</code>>></p><p>An injection key that a ContextComponent will use to provide a ref to a bounding rect of the Context.</p><h4 id="defined-in-2" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-2" aria-label="Permalink to "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/8c0a0c4/src/game/layers.tsx#L52" target="_blank" rel="noreferrer">profectus/src/game/layers.tsx:52</a></p><hr><h3 id="nodesinjectionkey" tabindex="-1">NodesInjectionKey <a class="header-anchor" href="#nodesinjectionkey" aria-label="Permalink to "NodesInjectionKey""></a></h3><p>• <code>Const</code> <strong>NodesInjectionKey</strong>: <code>InjectionKey</code><<code>Ref</code><<a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type" target="_blank" rel="noreferrer"><code>Record</code></a><<code>string</code>, <a href="../../interfaces/game/layers.FeatureNode"><code>FeatureNode</code></a> | <code>undefined</code>>>></p><p>An injection key that a ContextComponent will use to provide a ref to a map of all currently registered <a href="../../interfaces/game/layers.FeatureNode">FeatureNode</a>s.</p><h4 id="defined-in-3" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-3" aria-label="Permalink to "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/8c0a0c4/src/game/layers.tsx#L47" target="_blank" rel="noreferrer">profectus/src/game/layers.tsx:47</a></p><hr><h3 id="registernodeinjectionkey" tabindex="-1">RegisterNodeInjectionKey <a class="header-anchor" href="#registernodeinjectionkey" aria-label="Permalink to "RegisterNodeInjectionKey""></a></h3><p>• <code>Const</code> <strong>RegisterNodeInjectionKey</strong>: <code>InjectionKey</code><(<code>id</code>: <code>string</code>, <code>element</code>: <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement" target="_blank" rel="noreferrer"><code>HTMLElement</code></a>) => <code>void</code>></p><p>An injection key that a ContextComponent will use to provide a function that registers a <a href="../../interfaces/game/layers.FeatureNode">FeatureNode</a> with the given id and HTML element.</p><h4 id="defined-in-4" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-4" aria-label="Permalink to "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/8c0a0c4/src/game/layers.tsx#L37" target="_blank" rel="noreferrer">profectus/src/game/layers.tsx:37</a></p><hr><h3 id="unregisternodeinjectionkey" tabindex="-1">UnregisterNodeInjectionKey <a class="header-anchor" href="#unregisternodeinjectionkey" aria-label="Permalink to "UnregisterNodeInjectionKey""></a></h3><p>• <code>Const</code> <strong>UnregisterNodeInjectionKey</strong>: <code>InjectionKey</code><(<code>id</code>: <code>string</code>) => <code>void</code>></p><p>An injection key that a ContextComponent will use to provide a function that unregisters a <a href="../../interfaces/game/layers.FeatureNode">FeatureNode</a> with the given id.</p><h4 id="defined-in-5" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-5" aria-label="Permalink to "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/8c0a0c4/src/game/layers.tsx#L42" target="_blank" rel="noreferrer">profectus/src/game/layers.tsx:42</a></p><hr><h3 id="addinglayers" tabindex="-1">addingLayers <a class="header-anchor" href="#addinglayers" aria-label="Permalink to "addingLayers""></a></h3><p>• <code>Const</code> <strong>addingLayers</strong>: <code>string</code>[] = <code>[]</code></p><p>When creating layers, this array stores the layers currently being created, as a stack.</p><h4 id="defined-in-6" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-6" aria-label="Permalink to "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/8c0a0c4/src/game/layers.tsx#L200" target="_blank" rel="noreferrer">profectus/src/game/layers.tsx:200</a></p><hr><h3 id="layers" tabindex="-1">layers <a class="header-anchor" href="#layers" aria-label="Permalink to "layers""></a></h3><p>• <code>Const</code> <strong>layers</strong>: <a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type" target="_blank" rel="noreferrer"><code>Record</code></a><<code>string</code>, <a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#readonlytype" target="_blank" rel="noreferrer"><code>Readonly</code></a><<a href="./layers#genericlayer"><code>GenericLayer</code></a>> | <code>undefined</code>></p><p>A reference to all the current layers. It is shallow reactive so it will update when layers are added or removed, but not interfere with the existing refs within each layer.</p><h4 id="defined-in-7" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-7" aria-label="Permalink to "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/8c0a0c4/src/game/layers.tsx#L77" target="_blank" rel="noreferrer">profectus/src/game/layers.tsx:77</a></p><hr><h3 id="persistentrefs" tabindex="-1">persistentRefs <a class="header-anchor" href="#persistentrefs" aria-label="Permalink to "persistentRefs""></a></h3><p>• <code>Const</code> <strong>persistentRefs</strong>: <a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type" target="_blank" rel="noreferrer"><code>Record</code></a><<code>string</code>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set" target="_blank" rel="noreferrer"><code>Set</code></a><<a href="./persistence#persistent"><code>Persistent</code></a>>> = <code>{}</code></p><p>When creating layers, this object a map of layer ID to a set of any created persistent refs in order to check they're all included in the final layer object.</p><h4 id="defined-in-8" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-8" aria-label="Permalink to "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/8c0a0c4/src/game/layers.tsx#L196" target="_blank" rel="noreferrer">profectus/src/game/layers.tsx:196</a></p><h2 id="functions" tabindex="-1">Functions <a class="header-anchor" href="#functions" aria-label="Permalink to "Functions""></a></h2><h3 id="addlayer" tabindex="-1">addLayer <a class="header-anchor" href="#addlayer" aria-label="Permalink to "addLayer""></a></h3><p>▸ <strong>addLayer</strong>(<code>layer</code>, <code>player</code>): <code>void</code></p><p>Enables a layer object, so it will be updated every tick. Note that accessing a layer/its properties does NOT require it to be enabled. For dynamic layers you can call this function and <a href="./layers#removelayer">removeLayer</a> as necessary. Just make sure <a href="./../data/projEntry#getinitiallayers">getInitialLayers</a> will provide an accurate list of layers based on the player data object. For static layers just make <a href="./../data/projEntry#getinitiallayers">getInitialLayers</a> return all the layers.</p><h4 id="parameters" tabindex="-1">Parameters <a class="header-anchor" href="#parameters" aria-label="Permalink to "Parameters""></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th><th style="text-align:left;">Description</th></tr></thead><tbody><tr><td style="text-align:left;"><code>layer</code></td><td style="text-align:left;"><a href="./layers#genericlayer"><code>GenericLayer</code></a></td><td style="text-align:left;">The layer to add.</td></tr><tr><td style="text-align:left;"><code>player</code></td><td style="text-align:left;"><code>Object</code></td><td style="text-align:left;">The player data object, which will have a data object for this layer.</td></tr><tr><td style="text-align:left;"><code>player.layers?</code></td><td style="text-align:left;"><a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type" target="_blank" rel="noreferrer"><code>Record</code></a><<code>string</code>, <a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type" target="_blank" rel="noreferrer"><code>Record</code></a><<code>string</code>, <code>unknown</code>>></td><td style="text-align:left;">-</td></tr></tbody></table><h4 id="returns" tabindex="-1">Returns <a class="header-anchor" href="#returns" aria-label="Permalink to "Returns""></a></h4><p><code>void</code></p><h4 id="defined-in-9" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-9" aria-label="Permalink to "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/8c0a0c4/src/game/layers.tsx#L284" target="_blank" rel="noreferrer">profectus/src/game/layers.tsx:284</a></p><hr><h3 id="createlayer" tabindex="-1">createLayer <a class="header-anchor" href="#createlayer" aria-label="Permalink to "createLayer""></a></h3><p>▸ <strong>createLayer</strong><<code>T</code>>(<code>id</code>, <code>optionsFunc</code>): <a href="./layers#layer"><code>Layer</code></a><<code>T</code>></p><p>Lazily creates a layer with the given options.</p><h4 id="type-parameters-1" tabindex="-1">Type parameters <a class="header-anchor" href="#type-parameters-1" aria-label="Permalink to "Type parameters""></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th></tr></thead><tbody><tr><td style="text-align:left;"><code>T</code></td><td style="text-align:left;">extends <a href="../../interfaces/game/layers.LayerOptions"><code>LayerOptions</code></a></td></tr></tbody></table><h4 id="parameters-1" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-1" aria-label="Permalink to "Parameters""></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th><th style="text-align:left;">Description</th></tr></thead><tbody><tr><td style="text-align:left;"><code>id</code></td><td style="text-align:left;"><code>string</code></td><td style="text-align:left;">The ID this layer will have. See <a href="./../../interfaces/game/layers.BaseLayer#id">id</a>.</td></tr><tr><td style="text-align:left;"><code>optionsFunc</code></td><td style="text-align:left;"><a href="./../features/feature#optionsfunc"><code>OptionsFunc</code></a><<code>T</code>, <a href="../../interfaces/game/layers.BaseLayer"><code>BaseLayer</code></a>, <a href="../../interfaces/game/layers.BaseLayer"><code>BaseLayer</code></a>></td><td style="text-align:left;">Layer options.</td></tr></tbody></table><h4 id="returns-1" tabindex="-1">Returns <a class="header-anchor" href="#returns-1" aria-label="Permalink to "Returns""></a></h4><p><a href="./layers#layer"><code>Layer</code></a><<code>T</code>></p><h4 id="defined-in-10" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-10" aria-label="Permalink to "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/8c0a0c4/src/game/layers.tsx#L206" target="_blank" rel="noreferrer">profectus/src/game/layers.tsx:206</a></p><hr><h3 id="getlayer" tabindex="-1">getLayer <a class="header-anchor" href="#getlayer" aria-label="Permalink to "getLayer""></a></h3><p>▸ <strong>getLayer</strong><<code>T</code>>(<code>layerID</code>): <code>T</code></p><p>Convenience method for getting a layer by its ID with correct typing.</p><h4 id="type-parameters-2" tabindex="-1">Type parameters <a class="header-anchor" href="#type-parameters-2" aria-label="Permalink to "Type parameters""></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th></tr></thead><tbody><tr><td style="text-align:left;"><code>T</code></td><td style="text-align:left;">extends <a href="./layers#genericlayer"><code>GenericLayer</code></a></td></tr></tbody></table><h4 id="parameters-2" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-2" aria-label="Permalink to "Parameters""></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th><th style="text-align:left;">Description</th></tr></thead><tbody><tr><td style="text-align:left;"><code>layerID</code></td><td style="text-align:left;"><code>string</code></td><td style="text-align:left;">The ID of the layer to get.</td></tr></tbody></table><h4 id="returns-2" tabindex="-1">Returns <a class="header-anchor" href="#returns-2" aria-label="Permalink to "Returns""></a></h4><p><code>T</code></p><h4 id="defined-in-11" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-11" aria-label="Permalink to "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/8c0a0c4/src/game/layers.tsx#L311" target="_blank" rel="noreferrer">profectus/src/game/layers.tsx:311</a></p><hr><h3 id="reloadlayer" tabindex="-1">reloadLayer <a class="header-anchor" href="#reloadlayer" aria-label="Permalink to "reloadLayer""></a></h3><p>▸ <strong>reloadLayer</strong>(<code>layer</code>): <code>void</code></p><p>Convenience method for removing and immediately re-adding a layer. This is useful for layers with dynamic content, to ensure persistent refs are correctly configured.</p><h4 id="parameters-3" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-3" aria-label="Permalink to "Parameters""></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th><th style="text-align:left;">Description</th></tr></thead><tbody><tr><td style="text-align:left;"><code>layer</code></td><td style="text-align:left;"><a href="./layers#genericlayer"><code>GenericLayer</code></a></td><td style="text-align:left;">Layer to remove and then re-add</td></tr></tbody></table><h4 id="returns-3" tabindex="-1">Returns <a class="header-anchor" href="#returns-3" aria-label="Permalink to "Returns""></a></h4><p><code>void</code></p><h4 id="defined-in-12" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-12" aria-label="Permalink to "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/8c0a0c4/src/game/layers.tsx#L332" target="_blank" rel="noreferrer">profectus/src/game/layers.tsx:332</a></p><hr><h3 id="removelayer" tabindex="-1">removeLayer <a class="header-anchor" href="#removelayer" aria-label="Permalink to "removeLayer""></a></h3><p>▸ <strong>removeLayer</strong>(<code>layer</code>): <code>void</code></p><p>Disables a layer, so it will no longer be updated every tick. Note that accessing a layer/its properties does NOT require it to be enabled.</p><h4 id="parameters-4" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-4" aria-label="Permalink to "Parameters""></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th><th style="text-align:left;">Description</th></tr></thead><tbody><tr><td style="text-align:left;"><code>layer</code></td><td style="text-align:left;"><a href="./layers#genericlayer"><code>GenericLayer</code></a></td><td style="text-align:left;">The layer to remove.</td></tr></tbody></table><h4 id="returns-4" tabindex="-1">Returns <a class="header-anchor" href="#returns-4" aria-label="Permalink to "Returns""></a></h4><p><code>void</code></p><h4 id="defined-in-13" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-13" aria-label="Permalink to "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/8c0a0c4/src/game/layers.tsx#L320" target="_blank" rel="noreferrer">profectus/src/game/layers.tsx:320</a></p><hr><h3 id="setuplayermodal" tabindex="-1">setupLayerModal <a class="header-anchor" href="#setuplayermodal" aria-label="Permalink to "setupLayerModal""></a></h3><p>▸ <strong>setupLayerModal</strong>(<code>layer</code>): <code>Object</code></p><p>Utility function for creating a modal that display's a <a href="./../../interfaces/game/layers.LayerOptions#display">display</a>. Returns the modal itself, which can be rendered anywhere you need, as well as a function to open the modal.</p><h4 id="parameters-5" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-5" aria-label="Permalink to "Parameters""></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th><th style="text-align:left;">Description</th></tr></thead><tbody><tr><td style="text-align:left;"><code>layer</code></td><td style="text-align:left;"><a href="./layers#genericlayer"><code>GenericLayer</code></a></td><td style="text-align:left;">The layer to display in the modal.</td></tr></tbody></table><h4 id="returns-5" tabindex="-1">Returns <a class="header-anchor" href="#returns-5" aria-label="Permalink to "Returns""></a></h4><p><code>Object</code></p><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th></tr></thead><tbody><tr><td style="text-align:left;"><code>modal</code></td><td style="text-align:left;"><a href="./../features/feature#jsxfunction"><code>JSXFunction</code></a></td></tr><tr><td style="text-align:left;"><code>openModal</code></td><td style="text-align:left;"><code>VoidFunction</code></td></tr></tbody></table><h4 id="defined-in-14" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-14" aria-label="Permalink to "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/8c0a0c4/src/game/layers.tsx#L344" target="_blank" rel="noreferrer">profectus/src/game/layers.tsx:344</a></p>',124),l=[d];function n(i,s,c,h,y,f){return a(),t("div",null,l)}const g=e(o,[["render",n]]);export{u as __pageData,g as default};
|