Skip to content
On this page

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:92


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:65


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:54

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:92


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


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:213


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:193


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

Returns

T[typeof NonPersistent]

Defined in

profectus/src/game/persistence.ts:201


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:129