Module: game/persistence
Type Aliases
Persistent
Ƭ Persistent<T
>: Ref
<T
> & { [DefaultValue]
: T
; [Deleted]
: boolean
; [PersistentState]
: Ref
<T
> ; [StackTrace]
: string
}
A Ref that has been augmented with properties to allow it to be saved and loaded within the player save data object.
Type parameters
Name | Type |
---|---|
T | extends State = State |
Defined in
profectus/src/game/persistence.ts:48
State
Ƭ State: string
| number
| boolean
| DecimalSource
| { [key: string]
: State
; } | { [key: number]
: State
; }
This is a union of things that should be safely stringifiable without needing special processes or knowing what to load them in as.
- Decimals aren't allowed because we'd need to know to parse them back.
- DecimalSources are allowed because the string is a valid value for them
Defined in
profectus/src/game/persistence.ts:37
Variables
DefaultValue
• Const
DefaultValue: typeof DefaultValue
A symbol used in Persistent objects.
See
Defined in
profectus/src/game/persistence.ts:20
Deleted
• Const
Deleted: typeof Deleted
A symbol used in Persistent objects.
See
Defined in
profectus/src/game/persistence.ts:30
PersistentState
• Const
PersistentState: typeof PersistentState
A symbol used in Persistent objects.
See
Defined in
profectus/src/game/persistence.ts:15
StackTrace
• Const
StackTrace: typeof StackTrace
A symbol used in Persistent objects.
See
Defined in
profectus/src/game/persistence.ts:25
Functions
deletePersistent
▸ deletePersistent(persistent
): void
Mark a Persistent as deleted, so it won't be saved and loaded. Since persistent refs must be created during a layer's options func, features can not create persistent refs after evaluating their own options funcs. As a result, it must create any persistent refs it might need. This function can then be called after the options func is evaluated to mark the persistent ref to not be saved or loaded.
Parameters
Name | Type |
---|---|
persistent | Persistent <State > |
Returns
void
persistent
▸ persistent<T
>(defaultValue
): Persistent
<T
>
Create a persistent ref, which can be saved and loaded. All (non-deleted) persistent refs must be included somewhere within the layer object returned by that layer's options func.
Type parameters
Name | Type |
---|---|
T | extends State |
Parameters
Name | Type | Description |
---|---|---|
defaultValue | T | Ref <T > | The value the persistent ref should start at on fresh saves or when reset. |
Returns
Persistent
<T
>