1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
import{_ as e,c as t,o as r,N as a}from"./chunks/framework.0799945b.js";const b=JSON.parse('{"title":"Module: features/resources/resource","description":"","frontmatter":{"editLink":false},"headers":[],"relativePath":"api/modules/features/resource.md","lastUpdated":null}'),o={name:"api/modules/features/resource.md"},s=a('<h1 id="module-features-resources-resource" tabindex="-1">Module: features/resources/resource <a class="header-anchor" href="#module-features-resources-resource" aria-label="Permalink to "Module: features/resources/resource""></a></h1><h2 id="interfaces" tabindex="-1">Interfaces <a class="header-anchor" href="#interfaces" aria-label="Permalink to "Interfaces""></a></h2><h3 id="resource" tabindex="-1">Resource <a class="header-anchor" href="#resource" aria-label="Permalink to "Resource""></a></h3><p>• <strong>Resource</strong><<code>T</code>>: <code>Object</code></p><p>An object that represents a named and quantifiable resource in the game.</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;"><a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a></td></tr></tbody></table><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>[RefSymbol]</code></td><td style="text-align:left;"><code>true</code></td><td style="text-align:left;">Type differentiator only. We need this to be in public d.ts but don't want it to show up in IDE autocomplete, so we use a private Symbol instead.</td></tr><tr><td style="text-align:left;"><code>displayName</code></td><td style="text-align:left;"><code>string</code></td><td style="text-align:left;">The name of this resource.</td></tr><tr><td style="text-align:left;"><code>precision</code></td><td style="text-align:left;"><code>number</code></td><td style="text-align:left;">When displaying the value of this resource, how many significant digits to display.</td></tr><tr><td style="text-align:left;"><code>small?</code></td><td style="text-align:left;"><code>boolean</code></td><td style="text-align:left;">Whether or not to display very small values using scientific notation, or rounding to 0.</td></tr><tr><td style="text-align:left;"><code>value</code></td><td style="text-align:left;"><code>T</code></td><td style="text-align:left;">-</td></tr></tbody></table><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/c386ace/src/features/resources/resource.ts#L12" target="_blank" rel="noreferrer">profectus/src/features/resources/resource.ts:12</a></p><h2 id="functions" tabindex="-1">Functions <a class="header-anchor" href="#functions" aria-label="Permalink to "Functions""></a></h2><h3 id="createresource" tabindex="-1">createResource <a class="header-anchor" href="#createresource" aria-label="Permalink to "createResource""></a></h3><p>▸ <strong>createResource</strong><<code>T</code>>(<code>defaultValue</code>, <code>displayName?</code>, <code>precision?</code>, <code>small?</code>): <a href="./resource#resource"><code>Resource</code></a><<code>T</code>> & <a href="./../game/persistence#persistent"><code>Persistent</code></a><<code>T</code>> & { <code>[NonPersistent]</code>: <a href="./resource#resource"><code>Resource</code></a><<code>T</code>> }</p><p>Creates a resource.</p><h5 id="type-parameters-1" tabindex="-1">Type parameters <a class="header-anchor" href="#type-parameters-1" aria-label="Permalink to "Type parameters""></a></h5><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="./../game/persistence#state"><code>State</code></a></td></tr></tbody></table><h5 id="parameters" tabindex="-1">Parameters <a class="header-anchor" href="#parameters" aria-label="Permalink to "Parameters""></a></h5><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></td><td style="text-align:left;">The initial value of the resource</td></tr><tr><td style="text-align:left;"><code>displayName?</code></td><td style="text-align:left;"><code>string</code></td><td style="text-align:left;">The human readable name of this resource</td></tr><tr><td style="text-align:left;"><code>precision?</code></td><td style="text-align:left;"><code>number</code></td><td style="text-align:left;">The number of significant digits to display by default</td></tr><tr><td style="text-align:left;"><code>small?</code></td><td style="text-align:left;"><code>boolean</code></td><td style="text-align:left;">Whether or not to display very small values or round to 0, by default</td></tr></tbody></table><h5 id="returns" tabindex="-1">Returns <a class="header-anchor" href="#returns" aria-label="Permalink to "Returns""></a></h5><p><a href="./resource#resource"><code>Resource</code></a><<code>T</code>> & <a href="./../game/persistence#persistent"><code>Persistent</code></a><<code>T</code>> & { <code>[NonPersistent]</code>: <a href="./resource#resource"><code>Resource</code></a><<code>T</code>> }</p><h4 id="other-signatures" tabindex="-1">Other signatures <a class="header-anchor" href="#other-signatures" aria-label="Permalink to "Other signatures""></a></h4><p>▸ <strong>createResource</strong><<code>T</code>>(<code>defaultValue</code>, <code>displayName?</code>, <code>precision?</code>, <code>small?</code>): <a href="./resource#resource"><code>Resource</code></a><<code>T</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>defaultValue</code></td><td style="text-align:left;"><code>Ref</code><<code>T</code>></td></tr><tr><td style="text-align:left;"><code>displayName?</code></td><td style="text-align:left;"><code>string</code></td></tr><tr><td style="text-align:left;"><code>precision?</code></td><td style="text-align:left;"><code>number</code></td></tr><tr><td style="text-align:left;"><code>small?</code></td><td style="text-align:left;"><code>boolean</code></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/c386ace/src/features/resources/resource.ts#L28" target="_blank" rel="noreferrer">profectus/src/features/resources/resource.ts:28</a></p><p><a href="https://github.com/profectus-engine/Profectus/blob/c386ace/src/features/resources/resource.ts#L34" target="_blank" rel="noreferrer">profectus/src/features/resources/resource.ts:34</a></p><p><a href="https://github.com/profectus-engine/Profectus/blob/c386ace/src/features/resources/resource.ts#L40" target="_blank" rel="noreferrer">profectus/src/features/resources/resource.ts:40</a></p><hr><h3 id="displayresource" tabindex="-1">displayResource <a class="header-anchor" href="#displayresource" aria-label="Permalink to "displayResource""></a></h3><p>▸ <strong>displayResource</strong>(<code>resource</code>, <code>overrideAmount?</code>): <code>string</code></p><p>Utility for displaying a resource with the correct precision.</p><h5 id="parameters-1" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-1" aria-label="Permalink to "Parameters""></a></h5><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>resource</code></td><td style="text-align:left;"><a href="./resource#resource"><code>Resource</code></a><<a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a>></td></tr><tr><td style="text-align:left;"><code>overrideAmount?</code></td><td style="text-align:left;"><a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a></td></tr></tbody></table><h5 id="returns-1" tabindex="-1">Returns <a class="header-anchor" href="#returns-1" aria-label="Permalink to "Returns""></a></h5><p><code>string</code></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/c386ace/src/features/resources/resource.ts#L153" target="_blank" rel="noreferrer">profectus/src/features/resources/resource.ts:153</a></p><hr><h3 id="trackbest" tabindex="-1">trackBest <a class="header-anchor" href="#trackbest" aria-label="Permalink to "trackBest""></a></h3><p>▸ <strong>trackBest</strong>(<code>resource</code>): <code>Ref</code><<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>></p><p>Returns a reference to the highest amount of the resource ever owned, which is updated automatically.</p><h5 id="parameters-2" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-2" aria-label="Permalink to "Parameters""></a></h5><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>resource</code></td><td style="text-align:left;"><a href="./resource#resource"><code>Resource</code></a><<a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a>></td></tr></tbody></table><h5 id="returns-2" tabindex="-1">Returns <a class="header-anchor" href="#returns-2" aria-label="Permalink to "Returns""></a></h5><p><code>Ref</code><<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>></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/c386ace/src/features/resources/resource.ts#L64" target="_blank" rel="noreferrer">profectus/src/features/resources/resource.ts:64</a></p><hr><h3 id="trackoomps" tabindex="-1">trackOOMPS <a class="header-anchor" href="#trackoomps" aria-label="Permalink to "trackOOMPS""></a></h3><p>▸ <strong>trackOOMPS</strong>(<code>resource</code>, <code>pointGain?</code>): <code>Ref</code><<code>string</code>></p><p>Returns a reference to the amount of resource being gained in terms of orders of magnitude per second, calcualted over the last tick. Useful for situations where the gain rate is increasing very rapidly.</p><h5 id="parameters-3" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-3" aria-label="Permalink to "Parameters""></a></h5><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>resource</code></td><td style="text-align:left;"><a href="./resource#resource"><code>Resource</code></a><<a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a>></td></tr><tr><td style="text-align:left;"><code>pointGain?</code></td><td style="text-align:left;"><code>ComputedRef</code><<a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a>></td></tr></tbody></table><h5 id="returns-3" tabindex="-1">Returns <a class="header-anchor" href="#returns-3" aria-label="Permalink to "Returns""></a></h5><p><code>Ref</code><<code>string</code>></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/c386ace/src/features/resources/resource.ts#L94" target="_blank" rel="noreferrer">profectus/src/features/resources/resource.ts:94</a></p><hr><h3 id="tracktotal" tabindex="-1">trackTotal <a class="header-anchor" href="#tracktotal" aria-label="Permalink to "trackTotal""></a></h3><p>▸ <strong>trackTotal</strong>(<code>resource</code>): <code>Ref</code><<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>></p><p>Returns a reference to the total amount of the resource gained, updated automatically. "Refunds" count as gain.</p><h5 id="parameters-4" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-4" aria-label="Permalink to "Parameters""></a></h5><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>resource</code></td><td style="text-align:left;"><a href="./resource#resource"><code>Resource</code></a><<a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a>></td></tr></tbody></table><h5 id="returns-4" tabindex="-1">Returns <a class="header-anchor" href="#returns-4" aria-label="Permalink to "Returns""></a></h5><p><code>Ref</code><<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>></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/c386ace/src/features/resources/resource.ts#L78" target="_blank" rel="noreferrer">profectus/src/features/resources/resource.ts:78</a></p><hr><h3 id="unwrapresource" tabindex="-1">unwrapResource <a class="header-anchor" href="#unwrapresource" aria-label="Permalink to "unwrapResource""></a></h3><p>▸ <strong>unwrapResource</strong>(<code>resource</code>): <a href="./resource#resource"><code>Resource</code></a></p><p>Utility for unwrapping a resource that may or may not be inside a ref.</p><h5 id="parameters-5" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-5" aria-label="Permalink to "Parameters""></a></h5><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>resource</code></td><td style="text-align:left;"><a href="./../util/computed#processedcomputable"><code>ProcessedComputable</code></a><<a href="./resource#resource"><code>Resource</code></a><<a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a>>></td></tr></tbody></table><h5 id="returns-5" tabindex="-1">Returns <a class="header-anchor" href="#returns-5" aria-label="Permalink to "Returns""></a></h5><p><a href="./resource#resource"><code>Resource</code></a></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/c386ace/src/features/resources/resource.ts#L162" target="_blank" rel="noreferrer">profectus/src/features/resources/resource.ts:162</a></p><h2 id="components" tabindex="-1">Components <a class="header-anchor" href="#components" aria-label="Permalink to "Components""></a></h2><h3 id="maindisplay-component" tabindex="-1">MainDisplay Component <a class="header-anchor" href="#maindisplay-component" aria-label="Permalink to "MainDisplay Component""></a></h3><h4 id="props" tabindex="-1">Props <a class="header-anchor" href="#props" aria-label="Permalink to "Props""></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>resource</code>*</td><td style="text-align:left;"><code>Resource</code></td></tr><tr><td style="text-align:left;"><code>color</code></td><td style="text-align:left;"><code>string</code></td></tr><tr><td style="text-align:left;"><code>classes</code></td><td style="text-align:left;"><code>Record</code></td></tr><tr><td style="text-align:left;"><code>style</code></td><td style="text-align:left;"><code>StyleValue</code></td></tr><tr><td style="text-align:left;"><code>effectDisplay</code></td><td style="text-align:left;"><code>CoercableComponent</code></td></tr></tbody></table><h3 id="resource-component" tabindex="-1">Resource Component <a class="header-anchor" href="#resource-component" aria-label="Permalink to "Resource Component""></a></h3><h4 id="props-1" tabindex="-1">Props <a class="header-anchor" href="#props-1" aria-label="Permalink to "Props""></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>resource</code>*</td><td style="text-align:left;"><code>Resource</code></td></tr><tr><td style="text-align:left;"><code>color</code>*</td><td style="text-align:left;"><code>string</code></td></tr></tbody></table>',84),d=[s];function c(l,n,i,u,h,f){return r(),t("div",null,d)}const g=e(o,[["render",c]]);export{b as __pageData,g as default};
|