import{_ as e,c as t,o as a,a as s}from"./app.ab34650d.js";const g=JSON.parse('{"title":"Module: game/persistence","description":"","frontmatter":{"editLink":false},"headers":[{"level":2,"title":"Type Aliases","slug":"type-aliases"},{"level":3,"title":"Persistent","slug":"persistent"},{"level":3,"title":"State","slug":"state"},{"level":2,"title":"Variables","slug":"variables"},{"level":3,"title":"DefaultValue","slug":"defaultvalue"},{"level":3,"title":"Deleted","slug":"deleted"},{"level":3,"title":"PersistentState","slug":"persistentstate"},{"level":3,"title":"StackTrace","slug":"stacktrace"},{"level":2,"title":"Functions","slug":"functions"},{"level":3,"title":"deletePersistent","slug":"deletepersistent"},{"level":3,"title":"persistent","slug":"persistent-1"}],"relativePath":"api/modules/game/persistence.md","lastUpdated":null}'),r={name:"api/modules/game/persistence.md"},n=s('
\u01AC 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.
Name | Type |
---|---|
T | extends State = State |
profectus/src/game/persistence.ts:48
\u01AC 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.
profectus/src/game/persistence.ts:37
\u2022 Const
DefaultValue: typeof DefaultValue
A symbol used in Persistent objects.
See
profectus/src/game/persistence.ts:20
\u2022 Const
Deleted: typeof Deleted
A symbol used in Persistent objects.
See
profectus/src/game/persistence.ts:30
\u2022 Const
PersistentState: typeof PersistentState
A symbol used in Persistent objects.
See
profectus/src/game/persistence.ts:15
\u2022 Const
StackTrace: typeof StackTrace
A symbol used in Persistent objects.
See
profectus/src/game/persistence.ts:25
\u25B8 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.
Name | Type |
---|---|
persistent | Persistent <State > |
void
\u25B8 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.
Name | Type |
---|---|
T | extends State |
Name | Type | Description |
---|---|---|
defaultValue | T | Ref <T > | The value the persistent ref should start at on fresh saves or when reset. |
Persistent
<T
>