import{_ as e,c as t,o as a,N as r}from"./chunks/framework.0799945b.js";const b=JSON.parse('{"title":"Module: game/persistence","description":"","frontmatter":{"editLink":false},"headers":[],"relativePath":"api/modules/game/persistence.md","lastUpdated":null}'),s={name:"api/modules/game/persistence.md"},n=r('
Ƭ NonPersistent<T
>: WritableComputedRef
<T
> & { [DefaultValue]
: T
}
Name | Type |
---|---|
T | extends State = State |
profectus/src/game/persistence.ts:37
profectus/src/game/persistence.ts:97
Ƭ Persistent<T
>: Ref
<T
> & { [CheckNaN]
: boolean
; [DefaultValue]
: T
; [Deleted]
: boolean
; [NonPersistent]
: NonPersistent
<T
> ; [PersistentState]
: Ref
<T
> ; [SaveDataPath]
: string
[] | undefined
; [StackTrace]
: string
; value
: T
}
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:70
Ƭ 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:59
• Const
CheckNaN: typeof CheckNaN
A symbol used in Persistent objects.
See
profectus/src/game/persistence.ts:47
• Const
DefaultValue: typeof DefaultValue
A symbol used in Persistent objects.
See
profectus/src/game/persistence.ts:22
• Const
Deleted: typeof Deleted
A symbol used in Persistent objects.
See
profectus/src/game/persistence.ts:32
• Const
NonPersistent: typeof NonPersistent
A symbol used in Persistent objects.
See
profectus/src/game/persistence.ts:37
profectus/src/game/persistence.ts:97
• Const
PersistentState: typeof PersistentState
A symbol used in Persistent objects.
See
profectus/src/game/persistence.ts:17
• Const
SaveDataPath: typeof SaveDataPath
A symbol used in Persistent objects.
See
profectus/src/game/persistence.ts:42
• Const
SkipPersistence: typeof SkipPersistence
A symbol used to flag objects that should not be checked for persistent values.
profectus/src/game/persistence.ts:52
• Const
StackTrace: typeof StackTrace
A symbol used in Persistent objects.
See
profectus/src/game/persistence.ts:27
▸ 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
profectus/src/game/persistence.ts:248
▸ isPersistent(value
): value is Persistent<State>
Type guard for whether an arbitrary value is a persistent ref
Name | Type | Description |
---|---|---|
value | unknown | The value that may or may not be a persistent ref |
value is Persistent<State>
profectus/src/game/persistence.ts:198
▸ noPersist<T
, S
>(persistent
): T
[typeof NonPersistent
]
Unwraps the non-persistent ref inside of persistent refs, to be passed to other features without duplicating values in the save data object.
Name | Type |
---|---|
T | extends Ref <S , T > & { [CheckNaN] : boolean ; [DefaultValue] : S ; [Deleted] : boolean ; [NonPersistent] : NonPersistent <S > ; [PersistentState] : Ref <S > ; [SaveDataPath] : undefined | string [] ; [StackTrace] : string ; value : S } |
S | extends State |
Name | Type | Description |
---|---|---|
persistent | T | The persistent ref to unwrap, or an object to ignore all persistent refs within |
T
[typeof NonPersistent
]
▸ noPersist<T
>(persistent
): T
Name | Type |
---|---|
persistent | T |
profectus/src/game/persistence.ts:206
profectus/src/game/persistence.ts:209
profectus/src/game/persistence.ts:210
▸ persistent<T
>(defaultValue
, checkNaN?
): 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 | Default value | Description |
---|---|---|---|
defaultValue | T | Ref <T > | undefined | The value the persistent ref should start at on fresh saves or when reset. |
checkNaN | boolean | true | Whether or not to check this ref for being NaN on set. Only use on refs that should always be DecimalSources. |
Persistent
<T
>