1 line
9.8 KiB
JavaScript
1 line
9.8 KiB
JavaScript
import{_ as e,c as t,o as a,a as s}from"./app.ab34650d.js";const g=JSON.parse('{"title":"Module: game/persistence","description":"","frontmatter":{"editLink":false},"headers":[{"level":2,"title":"Type Aliases","slug":"type-aliases"},{"level":3,"title":"Persistent","slug":"persistent"},{"level":3,"title":"State","slug":"state"},{"level":2,"title":"Variables","slug":"variables"},{"level":3,"title":"DefaultValue","slug":"defaultvalue"},{"level":3,"title":"Deleted","slug":"deleted"},{"level":3,"title":"PersistentState","slug":"persistentstate"},{"level":3,"title":"StackTrace","slug":"stacktrace"},{"level":2,"title":"Functions","slug":"functions"},{"level":3,"title":"deletePersistent","slug":"deletepersistent"},{"level":3,"title":"persistent","slug":"persistent-1"}],"relativePath":"api/modules/game/persistence.md","lastUpdated":null}'),r={name:"api/modules/game/persistence.md"},n=s('<h1 id="module-game-persistence" tabindex="-1">Module: game/persistence <a class="header-anchor" href="#module-game-persistence" aria-hidden="true">#</a></h1><h2 id="type-aliases" tabindex="-1">Type Aliases <a class="header-anchor" href="#type-aliases" aria-hidden="true">#</a></h2><h3 id="persistent" tabindex="-1">Persistent <a class="header-anchor" href="#persistent" aria-hidden="true">#</a></h3><p>\u01AC <strong>Persistent</strong><<code>T</code>>: <code>Ref</code><<code>T</code>> & { <code>[DefaultValue]</code>: <code>T</code> ; <code>[Deleted]</code>: <code>boolean</code> ; <code>[PersistentState]</code>: <code>Ref</code><<code>T</code>> ; <code>[StackTrace]</code>: <code>string</code> }</p><p>A Ref that has been augmented with properties to allow it to be saved and loaded within the player save data object.</p><h4 id="type-parameters" tabindex="-1">Type parameters <a class="header-anchor" href="#type-parameters" aria-hidden="true">#</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="./persistence.html#state"><code>State</code></a> = <a href="./persistence.html#state"><code>State</code></a></td></tr></tbody></table><h4 id="defined-in" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in" aria-hidden="true">#</a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/013092f/src/game/persistence.ts#L48" target="_blank" rel="noopener noreferrer">profectus/src/game/persistence.ts:48</a></p><hr><h3 id="state" tabindex="-1">State <a class="header-anchor" href="#state" aria-hidden="true">#</a></h3><p>\u01AC <strong>State</strong>: <code>string</code> | <code>number</code> | <code>boolean</code> | <a href="./../util/bignum.html#decimalsource"><code>DecimalSource</code></a> | { <code>[key: string]</code>: <a href="./persistence.html#state"><code>State</code></a>; } | { <code>[key: number]</code>: <a href="./persistence.html#state"><code>State</code></a>; }</p><p>This is a union of things that should be safely stringifiable without needing special processes or knowing what to load them in as.</p><ul><li>Decimals aren't allowed because we'd need to know to parse them back.</li><li>DecimalSources are allowed because the string is a valid value for them</li></ul><h4 id="defined-in-1" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-1" aria-hidden="true">#</a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/013092f/src/game/persistence.ts#L37" target="_blank" rel="noopener noreferrer">profectus/src/game/persistence.ts:37</a></p><h2 id="variables" tabindex="-1">Variables <a class="header-anchor" href="#variables" aria-hidden="true">#</a></h2><h3 id="defaultvalue" tabindex="-1">DefaultValue <a class="header-anchor" href="#defaultvalue" aria-hidden="true">#</a></h3><p>\u2022 <code>Const</code> <strong>DefaultValue</strong>: typeof <a href="./persistence.html#defaultvalue"><code>DefaultValue</code></a></p><p>A symbol used in <a href="./persistence.html#persistent">Persistent</a> objects.</p><p><strong><code>See</code></strong></p><p><a href="./persistence.html#persistent">[DefaultValue]</a></p><h4 id="defined-in-2" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-2" aria-hidden="true">#</a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/013092f/src/game/persistence.ts#L20" target="_blank" rel="noopener noreferrer">profectus/src/game/persistence.ts:20</a></p><hr><h3 id="deleted" tabindex="-1">Deleted <a class="header-anchor" href="#deleted" aria-hidden="true">#</a></h3><p>\u2022 <code>Const</code> <strong>Deleted</strong>: typeof <a href="./persistence.html#deleted"><code>Deleted</code></a></p><p>A symbol used in <a href="./persistence.html#persistent">Persistent</a> objects.</p><p><strong><code>See</code></strong></p><p><a href="./persistence.html#persistent">[Deleted]</a></p><h4 id="defined-in-3" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-3" aria-hidden="true">#</a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/013092f/src/game/persistence.ts#L30" target="_blank" rel="noopener noreferrer">profectus/src/game/persistence.ts:30</a></p><hr><h3 id="persistentstate" tabindex="-1">PersistentState <a class="header-anchor" href="#persistentstate" aria-hidden="true">#</a></h3><p>\u2022 <code>Const</code> <strong>PersistentState</strong>: typeof <a href="./persistence.html#persistentstate"><code>PersistentState</code></a></p><p>A symbol used in <a href="./persistence.html#persistent">Persistent</a> objects.</p><p><strong><code>See</code></strong></p><p><a href="./persistence.html#persistent">[PersistentState]</a></p><h4 id="defined-in-4" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-4" aria-hidden="true">#</a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/013092f/src/game/persistence.ts#L15" target="_blank" rel="noopener noreferrer">profectus/src/game/persistence.ts:15</a></p><hr><h3 id="stacktrace" tabindex="-1">StackTrace <a class="header-anchor" href="#stacktrace" aria-hidden="true">#</a></h3><p>\u2022 <code>Const</code> <strong>StackTrace</strong>: typeof <a href="./persistence.html#stacktrace"><code>StackTrace</code></a></p><p>A symbol used in <a href="./persistence.html#persistent">Persistent</a> objects.</p><p><strong><code>See</code></strong></p><p><a href="./persistence.html#persistent">[StackTrace]</a></p><h4 id="defined-in-5" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-5" aria-hidden="true">#</a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/013092f/src/game/persistence.ts#L25" target="_blank" rel="noopener noreferrer">profectus/src/game/persistence.ts:25</a></p><h2 id="functions" tabindex="-1">Functions <a class="header-anchor" href="#functions" aria-hidden="true">#</a></h2><h3 id="deletepersistent" tabindex="-1">deletePersistent <a class="header-anchor" href="#deletepersistent" aria-hidden="true">#</a></h3><p>\u25B8 <strong>deletePersistent</strong>(<code>persistent</code>): <code>void</code></p><p>Mark a <a href="./persistence.html#persistent">Persistent</a> as deleted, so it won't be saved and loaded. Since persistent refs must be created during a layer's options func, features can not create persistent refs after evaluating their own options funcs. As a result, it must create any persistent refs it <em>might</em> need. This function can then be called after the options func is evaluated to mark the persistent ref to not be saved or loaded.</p><h4 id="parameters" tabindex="-1">Parameters <a class="header-anchor" href="#parameters" aria-hidden="true">#</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>persistent</code></td><td style="text-align:left;"><a href="./persistence.html#persistent"><code>Persistent</code></a><<a href="./persistence.html#state"><code>State</code></a>></td></tr></tbody></table><h4 id="returns" tabindex="-1">Returns <a class="header-anchor" href="#returns" aria-hidden="true">#</a></h4><p><code>void</code></p><hr><h3 id="persistent-1" tabindex="-1">persistent <a class="header-anchor" href="#persistent-1" aria-hidden="true">#</a></h3><p>\u25B8 <strong>persistent</strong><<code>T</code>>(<code>defaultValue</code>): <a href="./persistence.html#persistent"><code>Persistent</code></a><<code>T</code>></p><p>Create a persistent ref, which can be saved and loaded. All (non-deleted) persistent refs must be included somewhere within the layer object returned by that layer's options func.</p><h4 id="type-parameters-1" tabindex="-1">Type parameters <a class="header-anchor" href="#type-parameters-1" aria-hidden="true">#</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="./persistence.html#state"><code>State</code></a></td></tr></tbody></table><h4 id="parameters-1" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-1" aria-hidden="true">#</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>defaultValue</code></td><td style="text-align:left;"><code>T</code> | <code>Ref</code><<code>T</code>></td><td style="text-align:left;">The value the persistent ref should start at on fresh saves or when reset.</td></tr></tbody></table><h4 id="returns-1" tabindex="-1">Returns <a class="header-anchor" href="#returns-1" aria-hidden="true">#</a></h4><p><a href="./persistence.html#persistent"><code>Persistent</code></a><<code>T</code>></p>',66),d=[n];function i(o,c,l,h,p,f){return a(),t("div",null,d)}var m=e(r,[["render",i]]);export{g as __pageData,m as default};
|