Talos docs

InstanceStore

Since 0.6
Plain text

Signature

export interface InstanceStore<T> {
  /** Build and record this entity's instance, replacing any existing one. */
  set(ctx: Keyed, value: T): T
  /** This entity's instance, or null. */
  get(ctx: Keyed): T | null
  /**
   * This entity's instance, building it if the behavior somehow ticked before `init` ran. Named `ensure`
   * rather than `require` so no bundle of a behavior ever contains the bare word the host's sandbox scan
   * looks for.
   */
  ensure(ctx: Keyed, make: () => T): T
  /** Forget this entity's instance. */
  drop(ctx: Keyed): void
  /** How many entities this module is live on; a leak check for tests. */
  readonly size: number
}

Import: import type { InstanceStore } from "@argus/gameplay"

Members

MemberSignatureDescription
setset(ctx: Keyed, value: T): TBuild and record this entity's instance, replacing any existing one.
getget(ctx: Keyed): T | nullThis entity's instance, or null.
ensureensure(ctx: Keyed, make: () => T): TThis entity's instance, building it if the behavior somehow ticked before init ran. Named ensure rather than require so no bundle of a behavior ever contains the bare word the host's sandbox scan looks for.
dropdrop(ctx: Keyed): voidForget this entity's instance.
sizereadonly size: numberHow many entities this module is live on; a leak check for tests.