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('
• Resource<T
>: Object
An object that represents a named and quantifiable resource in the game.
Name | Type |
---|---|
T | DecimalSource |
Name | Type | Description |
---|---|---|
[RefSymbol] | true | 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. |
displayName | string | The name of this resource. |
precision | number | When displaying the value of this resource, how many significant digits to display. |
small? | boolean | Whether or not to display very small values using scientific notation, or rounding to 0. |
value | T | - |
profectus/src/features/resources/resource.ts:12
▸ createResource<T
>(defaultValue
, displayName?
, precision?
, small?
): Resource
<T
> & Persistent
<T
> & { [NonPersistent]
: Resource
<T
> }
Creates a resource.
Name | Type |
---|---|
T | extends State |
Name | Type | Description |
---|---|---|
defaultValue | T | The initial value of the resource |
displayName? | string | The human readable name of this resource |
precision? | number | The number of significant digits to display by default |
small? | boolean | Whether or not to display very small values or round to 0, by default |
Resource
<T
> & Persistent
<T
> & { [NonPersistent]
: Resource
<T
> }
▸ createResource<T
>(defaultValue
, displayName?
, precision?
, small?
): Resource
<T
>
Name | Type |
---|---|
defaultValue | Ref <T > |
displayName? | string |
precision? | number |
small? | boolean |
profectus/src/features/resources/resource.ts:28
profectus/src/features/resources/resource.ts:34
profectus/src/features/resources/resource.ts:40
▸ displayResource(resource
, overrideAmount?
): string
Utility for displaying a resource with the correct precision.
Name | Type |
---|---|
resource | Resource <DecimalSource > |
overrideAmount? | DecimalSource |
string
profectus/src/features/resources/resource.ts:153
▸ trackBest(resource
): Ref
<DecimalSource
>
Returns a reference to the highest amount of the resource ever owned, which is updated automatically.
Name | Type |
---|---|
resource | Resource <DecimalSource > |
Ref
<DecimalSource
>
profectus/src/features/resources/resource.ts:64
▸ trackOOMPS(resource
, pointGain?
): Ref
<string
>
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.
Name | Type |
---|---|
resource | Resource <DecimalSource > |
pointGain? | ComputedRef <DecimalSource > |
Ref
<string
>
profectus/src/features/resources/resource.ts:94
▸ trackTotal(resource
): Ref
<DecimalSource
>
Returns a reference to the total amount of the resource gained, updated automatically. "Refunds" count as gain.
Name | Type |
---|---|
resource | Resource <DecimalSource > |
Ref
<DecimalSource
>
profectus/src/features/resources/resource.ts:78
▸ unwrapResource(resource
): Resource
Utility for unwrapping a resource that may or may not be inside a ref.
Name | Type |
---|---|
resource | ProcessedComputable <Resource <DecimalSource >> |
profectus/src/features/resources/resource.ts:162
Name | Type |
---|---|
resource * | Resource |
color | string |
classes | Record |
style | StyleValue |
effectDisplay | CoercableComponent |
Name | Type |
---|---|
resource * | Resource |
color * | string |