import{_ as e,c as t,o as r,N as a}from"./chunks/framework.0799945b.js";const m=JSON.parse('{"title":"Module: features/resources/resource","description":"","frontmatter":{"editLink":false},"headers":[],"relativePath":"api/modules/features/resources/resource.md","lastUpdated":null}'),o={name:"api/modules/features/resources/resource.md"},s=a('
▸ 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
> }
profectus/src/features/resources/resource.ts:28
▸ createResource<T
>(defaultValue
, displayName?
, precision?
, small?
): Resource
<T
>
Name | Type |
---|---|
T | extends State |
Name | Type |
---|---|
defaultValue | Ref <T > |
displayName? | string |
precision? | number |
small? | boolean |
Resource
<T
>
profectus/src/features/resources/resource.ts:34
▸ 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 >> |