Module: features/resources/resource
Interfaces
Resource
• Resource<T
>: Object
An object that represents a named and quantifiable resource in the game.
Type parameters
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 | - |
Defined in
profectus/src/features/resources/resource.ts:12
Functions
createResource
▸ createResource<T
>(defaultValue
, displayName?
, precision?
, small?
): Resource
<T
> & Persistent
<T
> & { [NonPersistent]
: Resource
<T
> }
Creates a resource.
Type parameters
Name | Type |
---|---|
T | extends State |
Parameters
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 |
Returns
Resource
<T
> & Persistent
<T
> & { [NonPersistent]
: Resource
<T
> }
Other signatures
▸ createResource<T
>(defaultValue
, displayName?
, precision?
, small?
): Resource
<T
>
Name | Type |
---|---|
defaultValue | Ref <T > |
displayName? | string |
precision? | number |
small? | boolean |
Defined in
profectus/src/features/resources/resource.ts:28
profectus/src/features/resources/resource.ts:34
profectus/src/features/resources/resource.ts:40
displayResource
▸ displayResource(resource
, overrideAmount?
): string
Utility for displaying a resource with the correct precision.
Parameters
Name | Type |
---|---|
resource | Resource <DecimalSource > |
overrideAmount? | DecimalSource |
Returns
string
Defined in
profectus/src/features/resources/resource.ts:153
trackBest
▸ trackBest(resource
): Ref
<DecimalSource
>
Returns a reference to the highest amount of the resource ever owned, which is updated automatically.
Parameters
Name | Type |
---|---|
resource | Resource <DecimalSource > |
Returns
Ref
<DecimalSource
>
Defined in
profectus/src/features/resources/resource.ts:64
trackOOMPS
▸ 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.
Parameters
Name | Type |
---|---|
resource | Resource <DecimalSource > |
pointGain? | ComputedRef <DecimalSource > |
Returns
Ref
<string
>
Defined in
profectus/src/features/resources/resource.ts:94
trackTotal
▸ trackTotal(resource
): Ref
<DecimalSource
>
Returns a reference to the total amount of the resource gained, updated automatically. "Refunds" count as gain.
Parameters
Name | Type |
---|---|
resource | Resource <DecimalSource > |
Returns
Ref
<DecimalSource
>
Defined in
profectus/src/features/resources/resource.ts:78
unwrapResource
▸ unwrapResource(resource
): Resource
Utility for unwrapping a resource that may or may not be inside a ref.
Parameters
Name | Type |
---|---|
resource | ProcessedComputable <Resource <DecimalSource >> |
Returns
Defined in
profectus/src/features/resources/resource.ts:162
Components
MainDisplay Component
Props
Name | Type |
---|---|
resource * | Resource |
color | string |
classes | Record |
style | StyleValue |
effectDisplay | CoercableComponent |
Resource Component
Props
Name | Type |
---|---|
resource * | Resource |
color * | string |