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('

Module: game/persistence

Type Aliases

NonPersistent

Ƭ NonPersistent<T>: WritableComputedRef<T> & { [DefaultValue]: T }

Type parameters

NameType
Textends State = State

Defined in

profectus/src/game/persistence.ts:37

profectus/src/game/persistence.ts:97


Persistent

Ƭ 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.

Type parameters

NameType
Textends State = State

Defined in

profectus/src/game/persistence.ts:70


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.

Defined in

profectus/src/game/persistence.ts:59

Variables

CheckNaN

Const CheckNaN: typeof CheckNaN

A symbol used in Persistent objects.

See

[CheckNaN]

Defined in

profectus/src/game/persistence.ts:47


DefaultValue

Const DefaultValue: typeof DefaultValue

A symbol used in Persistent objects.

See

[DefaultValue]

Defined in

profectus/src/game/persistence.ts:22


Deleted

Const Deleted: typeof Deleted

A symbol used in Persistent objects.

See

[Deleted]

Defined in

profectus/src/game/persistence.ts:32


NonPersistent

Const NonPersistent: typeof NonPersistent

A symbol used in Persistent objects.

See

[NonPersistent]

Defined in

profectus/src/game/persistence.ts:37

profectus/src/game/persistence.ts:97


PersistentState

Const PersistentState: typeof PersistentState

A symbol used in Persistent objects.

See

[PersistentState]

Defined in

profectus/src/game/persistence.ts:17


SaveDataPath

Const SaveDataPath: typeof SaveDataPath

A symbol used in Persistent objects.

See

[SaveDataPath]

Defined in

profectus/src/game/persistence.ts:42


SkipPersistence

Const SkipPersistence: typeof SkipPersistence

A symbol used to flag objects that should not be checked for persistent values.

Defined in

profectus/src/game/persistence.ts:52


StackTrace

Const StackTrace: typeof StackTrace

A symbol used in Persistent objects.

See

[StackTrace]

Defined in

profectus/src/game/persistence.ts:27

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
NameType
persistentPersistent<State>
Returns

void

Defined in

profectus/src/game/persistence.ts:248


isPersistent

isPersistent(value): value is Persistent<State>

Type guard for whether an arbitrary value is a persistent ref

Parameters
NameTypeDescription
valueunknownThe value that may or may not be a persistent ref
Returns

value is Persistent<State>

Defined in

profectus/src/game/persistence.ts:198


noPersist

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.

Type parameters
NameType
Textends Ref<S, T> & { [CheckNaN]: boolean ; [DefaultValue]: S ; [Deleted]: boolean ; [NonPersistent]: NonPersistent<S> ; [PersistentState]: Ref<S> ; [SaveDataPath]: undefined | string[] ; [StackTrace]: string ; value: S }
Sextends State
Parameters
NameTypeDescription
persistentTThe persistent ref to unwrap, or an object to ignore all persistent refs within
Returns

T[typeof NonPersistent]

Other signatures

noPersist<T>(persistent): T

NameType
persistentT

Defined in

profectus/src/game/persistence.ts:206

profectus/src/game/persistence.ts:209

profectus/src/game/persistence.ts:210


persistent

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.

Type parameters
NameType
Textends State
Parameters
NameTypeDefault valueDescription
defaultValueT | Ref<T>undefinedThe value the persistent ref should start at on fresh saves or when reset.
checkNaNbooleantrueWhether or not to check this ref for being NaN on set. Only use on refs that should always be DecimalSources.
Returns

Persistent<T>

Defined in

profectus/src/game/persistence.ts:134

',136),o=[n];function i(d,c,l,h,p,f){return a(),t("div",null,o)}const g=e(s,[["render",i]]);export{b as __pageData,g as default};