import{_ as e,c as t,o,N as a}from"./chunks/framework.0799945b.js";const m=JSON.parse('{"title":"Module: features/conversion","description":"","frontmatter":{"editLink":false},"headers":[],"relativePath":"api/modules/features/conversion.md","lastUpdated":null}'),r={name:"api/modules/features/conversion.md"},n=a('
Ƭ Conversion<T
>: Replace
<T
& BaseConversion
, { actualGain
: GetComputableTypeWithDefault
<T
["actualGain"
], Ref
<DecimalSource
>> ; buyMax
: GetComputableTypeWithDefault
<T
["buyMax"
], true
> ; currentAt
: GetComputableTypeWithDefault
<T
["currentAt"
], Ref
<DecimalSource
>> ; currentGain
: GetComputableTypeWithDefault
<T
["currentGain"
], Ref
<DecimalSource
>> ; formula
: InvertibleFormula
; nextAt
: GetComputableTypeWithDefault
<T
["nextAt"
], Ref
<DecimalSource
>> ; spend
: undefined
extends T
["spend"
] ? (amountGained
: DecimalSource
) => void
: T
["spend"
] }>
An object that converts one Resource into another at a given rate.
Name | Type |
---|---|
T | extends ConversionOptions |
profectus/src/features/conversion.ts:92
Ƭ GenericConversion: Replace
<Conversion
<ConversionOptions
>, { actualGain
: ProcessedComputable
<DecimalSource
> ; buyMax
: ProcessedComputable
<boolean
> ; currentAt
: ProcessedComputable
<DecimalSource
> ; currentGain
: ProcessedComputable
<DecimalSource
> ; nextAt
: ProcessedComputable
<DecimalSource
> ; spend
: (amountGained
: DecimalSource
) => void
}>
A type that matches any valid Conversion object.
profectus/src/features/conversion.ts:106
▸ createConversion<T
>(optionsFunc
): Conversion
<T
>
Lazily creates a conversion with the given options. You typically shouldn't use this function directly. Instead use one of the other conversion constructors, which will then call this.
See
Name | Type |
---|---|
T | extends ConversionOptions |
Name | Type | Description |
---|---|---|
optionsFunc | OptionsFunc <T , BaseConversion , GenericConversion > | Conversion options. |
Conversion
<T
>
profectus/src/features/conversion.ts:125
▸ createCumulativeConversion<S
>(optionsFunc
): Conversion
<S
>
Creates a conversion that simply adds to the gainResource amount upon converting. This is similar to the behavior of "normal" layers in The Modding Tree. This is equivalent to just calling createConversion directly.
Name | Type |
---|---|
S | extends ConversionOptions |
Name | Type | Description |
---|---|---|
optionsFunc | OptionsFunc <S , BaseConversion , GenericConversion > | Conversion options. |
Conversion
<S
>
profectus/src/features/conversion.ts:200
▸ createIndependentConversion<S
>(optionsFunc
): Conversion
<S
>
Creates a conversion that will replace the gainResource amount with the new amount upon converting. This is similar to the behavior of "static" layers in The Modding Tree.
Name | Type |
---|---|
S | extends ConversionOptions |
Name | Type | Description |
---|---|---|
optionsFunc | OptionsFunc <S , BaseConversion , GenericConversion > | Converison options. |
Conversion
<S
>
profectus/src/features/conversion.ts:211
▸ setupPassiveGeneration(layer
, conversion
, rate?
, cap?
): void
This will automatically increase the value of conversion.gainResource without lowering the value of the input resource. It will by default perform 100% of a conversion's currentGain per second. If you use a ref for the rate you can set it's value to 0 when passive generation should be disabled.
Name | Type | Default value | Description |
---|---|---|---|
layer | BaseLayer | undefined | The layer this passive generation will be associated with. Typically this when calling this function from inside a layer's options function. |
conversion | GenericConversion | undefined | The conversion that will determine how much generation there is. |
rate | Computable <DecimalSource > | 1 | A multiplier to multiply against the conversion's currentGain. |
cap | Computable <DecimalSource > | Decimal.dInf | A value that should not be passed via passive generation. |
void