Skip to content

LoadingSceneProgressBar

Defined in: ui/src/LoadingSceneProgressBar.ts:67

Not @serializable: the loading bar is a transient UI for a transient scene. Mid-load save/restore is not a supported flow — by the time the snapshot is loaded, the destination scene should be active.

  • Entity

new LoadingSceneProgressBar(name?, tags?): LoadingSceneProgressBar

Defined in: core/dist/index.d.ts:337

string

Iterable<string, any, any>

LoadingSceneProgressBar

Entity.constructor

readonly id: number

Defined in: core/dist/index.d.ts:290

Unique auto-incrementing ID.

Entity.id


readonly optional key?: string

Defined in: core/dist/index.d.ts:301

Stable identity key, scene-scoped. Set at spawn-time when options.key is passed to scene.spawn / entity.spawnChild; undefined otherwise. Used with scene.findByKey and as a stable id in reactive stores (e.g. a createSet<string>() persisted under "world.opened").

Entity.key


readonly name: string

Defined in: core/dist/index.d.ts:292

Display name for debugging.

Entity.name


readonly tags: Set<string>

Defined in: core/dist/index.d.ts:294

Tags for group queries.

Entity.tags


timeScale: number

Defined in: core/dist/index.d.ts:315

Per-entity time-scale multiplier. Mirrors Scene.timeScale but scoped to this single entity: the engine composes the delta time passed to this entity’s components (and its ProcessComponent, particle emitters) as dt * scene.timeScale * entity.timeScale. 1 = normal speed, 0.5 = half speed, 0 = frozen, 2 = double speed.

Physics is deliberately NOT affected: PhysicsSystem steps a single shared Rapier world per scene under scene.timeScale only, so a rigid-body entity’s simulation cannot be individually slowed or sped up via this field. Use a kinematic body or scale velocities manually if you need per-body time control.

Entity.timeScale


static [TRAITS_KEY]: Set<symbol>

Defined in: core/dist/index.d.ts:288

Entity.[TRAITS_KEY]

get activeSelf(): boolean

Defined in: core/dist/index.d.ts:420

This entity’s own activeness bit — what setActive last wrote. An entity whose activeSelf is true can still be dormant, if an ancestor is not. Use isActive for the state the engine acts on.

boolean

Entity.activeSelf


get children(): ReadonlyMap<string, Entity>

Defined in: core/dist/index.d.ts:450

Named children as a read-only map. Empty map if no children.

ReadonlyMap<string, Entity>

Entity.children


get generation(): number

Defined in: core/dist/index.d.ts:371

Which life of this entity is current. An EntityPool member is reused, so one object serves many lives; the counter moves on whenever a life ends, by release or by destruction. handle compares against it. Compare for equality only — a destruction cascade can advance it more than once, so it does not count lives. Written by the engine only.

number

Entity.generation


get isActive(): boolean

Defined in: core/dist/index.d.ts:427

Whether the entity is active: its own activeSelf and every ancestor’s. A dormant entity keeps all of its components and its place in scene.getEntities(), but drops out of queries, findEntity, findEntitiesByTag and findEntities, and its components stop updating.

boolean

Entity.isActive


get isDestroyed(): boolean

Defined in: core/dist/index.d.ts:357

True once the entity is dead — after destroy() is called, or once its scene starts tearing it down on scene exit.

boolean

Entity.isDestroyed


get isPooled(): boolean

Defined in: core/dist/index.d.ts:363

True while an EntityPool owns this entity. Pool members are left out of save snapshots: a pool restores empty and refills, so whatever was in flight when the game was saved is gone on load.

boolean

Entity.isPooled


get parent(): Entity | null

Defined in: core/dist/index.d.ts:448

The parent entity, or null if this is a root entity.

Entity | null

Entity.parent


get scene(): Scene

Defined in: core/dist/index.d.ts:350

The scene this entity belongs to. Throws if the entity is not attached to a scene — which in practice only happens before scene.spawn / addChild wires it up, or after the entity is destroyed (end-of-frame flush after destroy(), or scene teardown on exit). Inside lifecycle methods (setup, component onAdd, update, and component onDestroy during destruction) this is always safe to access.

For the rare case where you genuinely need to inspect whether an entity has a scene (e.g. defensive code in systems iterating a query result), use tryScene instead.

Scene

Entity.scene


get tryScene(): Scene | null

Defined in: core/dist/index.d.ts:352

The scene this entity belongs to, or null if detached.

Scene | null

Entity.tryScene

_componentsInUpdateOrder(): Iterable<Component>

Defined in: core/dist/index.d.ts:505

Internal

Internal: components in the order ComponentUpdateSystem calls them — ascending updatePriority, ties in add order. Identical to getAll() until a component declares a priority. The sorted array is replaced, not mutated, when a component is added or removed, so a pass already iterating it finishes over the old order; a component added mid-pass first runs next frame. The map iterator on the default path is live, so there a component added mid-pass can run in the same pass.

Iterable<Component>

Entity._componentsInUpdateOrder


_destroyOwned(): void

Defined in: core/dist/index.d.ts:530

Internal

Internal: destroy for real, skipping the pool redirect. Used by the owning pool when it disposes, and by the cascade below.

void

Entity._destroyOwned


_endLife(): void

Defined in: core/dist/index.d.ts:569

Internal

Internal: end this life so handles taken during it stop resolving. The subtree follows, because it is released or destroyed with this entity. Called by EntityPool when a lease ends; destruction goes through _markDestroyed instead.

void

Entity._endLife


_invalidateUpdateOrder(component): void

Defined in: core/dist/index.d.ts:513

Internal

Internal: a component was added or its updatePriority was written. Switches the entity onto the sorted update path once any component leaves the default priority, and drops the cached order so the next update pass rebuilds it.

Component

void

Entity._invalidateUpdateOrder


_markDestroyed(): void

Defined in: core/dist/index.d.ts:561

Internal

Internal: mark the entity destroyed without queueing it. Called by Scene during teardown so every entity reads isDestroyed === true before any component onDestroy runs, and by _destroyOwned. Idempotent, and the one place a destruction ends a life.

void

Entity._markDestroyed


_markPooled(owner): void

Defined in: core/dist/index.d.ts:414

Internal

Internal: mark the entity as a pool member. Called by EntityPool when it constructs one.

EntityPoolOwner

void

Entity._markPooled


_performDestroy(): void

Defined in: core/dist/index.d.ts:575

Internal

Internal: perform actual destruction — remove all components and clear state. Called by Scene during endOfFrame flush.

void

Entity._performDestroy


_resyncActive(): void

Defined in: core/dist/index.d.ts:538

Internal

Internal: recompute effective activeness against the current parent and propagate to descendants. Called after setActive, after a re-parent, and once per restored root when a snapshot finishes rebuilding the hierarchy.

void

Entity._resyncActive


_setActiveSuppressed(activeSelf): void

Defined in: core/dist/index.d.ts:546

Internal

Internal: write activeSelf and park the entity as dormant without firing hooks or touching queries. Used by snapshot restore, which must hold every restored entity inert until the parent links are back — the single _resyncActive per root afterwards fires each hook exactly once.

boolean

void

Entity._setActiveSuppressed


_setKey(key): void

Defined in: core/dist/index.d.ts:626

Internal

Internal: assign the stable identity key. Called by Scene._registerKey during spawn. Throws if the entity already has a key — keys are immutable for an entity’s lifetime.

string

void

Entity._setKey


_setScene(scene, callbacks): void

Defined in: core/dist/index.d.ts:619

Internal

Internal: set the scene and callbacks. Called by Scene.spawn().

Scene | null

EntityCallbacks | null

void

Entity._setScene


add<C>(component): C

Defined in: core/dist/index.d.ts:479

Add a component instance. Returns the component for chaining.

C extends Component

C

C

Entity.add


addChild(name, child): void

Defined in: core/dist/index.d.ts:452

Add a named child entity. Auto-adds to parent’s scene if not already in one.

string

Entity

void

Entity.addChild


optional afterRestore(data, resolve): void

Defined in: core/dist/index.d.ts:606

Called after components are restored during save/load. Rebuild non-serializable state here.

unknown

SnapshotResolver

void

Entity.afterRestore


destroy(): void

Defined in: core/dist/index.d.ts:524

Retire the entity. For an ordinary entity that means deferred destruction, with the real cleanup at end of frame.

A pool member is retired by going back to its pool instead — its pool owns its lifetime and destroys it only when the pool itself is disposed. That keeps destroy() usable from the places retirement is actually decided: a collision handler, an update, an event listener, all of which see a plain Entity and hold no pool reference.

void

Entity.destroy


emit(token): void

Defined in: core/dist/index.d.ts:491

Emit a typed event on this entity. Bubbles to the scene.

EventToken<void>

void

Entity.emit

emit<T>(token, data): void

Defined in: core/dist/index.d.ts:492

Emit a typed event on this entity. Bubbles to the scene.

T

EventToken<T>

T

void

Entity.emit


get<C>(cls): C

Defined in: core/dist/index.d.ts:481

Get a component by class. Throws if not found.

C extends Component

ComponentClass<C>

C

Entity.get


getAll(): Iterable<Component>

Defined in: core/dist/index.d.ts:494

Get all components as an iterable, in add order.

Iterable<Component>

Entity.getAll


getChild(name): Entity

Defined in: core/dist/index.d.ts:475

Get a child by name. Throws if not found.

string

Entity

Entity.getChild


handle(): EntityHandle<LoadingSceneProgressBar>

Defined in: core/dist/index.d.ts:401

Capture a reference that expires with this entity’s current life, read back through .current.

class Turret extends Entity {
private target?: EntityHandle<Enemy>;
onSpotted(enemy: Enemy) { this.target = enemy.handle(); }
update() {
const enemy = this.target?.current; // undefined once that enemy is gone
if (enemy) this.aimAt(enemy);
}
}

Take a handle whenever pooled entities are involved — a member can be retired from anywhere, so a stored plain reference goes stale silently. A plain reference is fine for entities that live as long as the scene, or when the code storing the reference also controls when the entity goes away.

A handle taken outside a live life never resolves: on a pool member (or an entity under one) whose pool is not currently lending it out, or on an entity that is destroyed or sits under a destroyed ancestor. In all of those the caller is holding a reference from a life that is already over.

EntityHandle<LoadingSceneProgressBar>

Entity.handle


has(cls): boolean

Defined in: core/dist/index.d.ts:485

Check if entity has a component of the given class.

ComponentClass

boolean

Entity.has


hasTrait<T>(token): this is LoadingSceneProgressBar & T

Defined in: core/dist/index.d.ts:608

Check if this entity’s class implements a given trait. Acts as a type guard.

T

TraitToken<T>

this is LoadingSceneProgressBar & T

Entity.hasTrait


on<T>(token, handler): () => void

Defined in: core/dist/index.d.ts:489

Subscribe to a typed event on this entity. Returns an unsubscribe function.

T

EventToken<T>

(data) => void

() => void

Entity.on


optional onAcquire(…args): void

Defined in: core/dist/index.d.ts:595

Per-reuse reset, called by EntityPool every time the entity is handed out — including the first time, right after setup(). Its parameters become the pool’s acquire(...) arguments, so a bullet that needs a position and a direction declares onAcquire(x: number, y: number, dir: Vec2).

A pooled class must declare this hook: nothing else resets the state the entity kept while dormant. Declare an empty one if there is genuinely nothing to reset. It runs on a fully active entity, and must be synchronous and non-overloaded — the pool derives acquire’s signature from it, and a set of overloads keeps only the last.

unknown[]

void

Entity.onAcquire


optional onRelease(): void

Defined in: core/dist/index.d.ts:602

Called by EntityPool when the entity is released, before it goes dormant. Optional even for pooled classes: turning components off is the job of onDisable, so this is for game-level cleanup — dropping a target reference, clearing a listener registered outside setup().

void

Entity.onRelease


remove(cls): void

Defined in: core/dist/index.d.ts:487

Remove a component by class.

ComponentClass

void

Entity.remove


removeChild(name): Entity

Defined in: core/dist/index.d.ts:473

Remove a named child. Returns the detached entity.

string

Entity

Entity.removeChild


requireKey(): string

Defined in: core/dist/index.d.ts:614

Return the stable key, or throw if this entity was spawned without one. Use inside component setup() when the component depends on identity (e.g. reading from a createSet keyed by entity key).

string

Entity.requireKey


optional serialize(): unknown

Defined in: core/dist/index.d.ts:604

Return a JSON-serializable snapshot of this entity’s custom state. Used by the save system.

unknown

Entity.serialize


setActive(active): void

Defined in: core/dist/index.d.ts:446

Turn the entity on or off without destroying it. Descendants follow: a child of a dormant entity is dormant whatever its own activeSelf says.

Components whose effective enabled-ness flips get onDisable / onEnable. Per-component enabled flags are left alone, so a component you disabled by hand stays disabled after the entity comes back.

bullet.setActive(false); // hidden, updates skipped
bullet.get(Transform).setPosition(x, y);
bullet.setActive(true); // back in play, no respawn

An entity with a RigidBodyComponent must be moved through rb.setPosition(x, y) instead — physics owns the transform of a dynamic body and overwrites a direct Transform write on the next frame.

boolean

void

Entity.setActive


setup(opts?): void

Defined in: ui/src/LoadingSceneProgressBar.ts:68

Optional setup method. Called by scene.spawn(Class, params) after the entity is wired to its scene, so components can access services. Override in subclasses — do NOT use the constructor for component setup.

LoadingSceneProgressBarOptions = {}

void

Entity.setup


spawnChild(name, options?): Entity

Defined in: core/dist/index.d.ts:468

Spawn a new entity in this entity’s scene and add it as a named child. Combines scene.spawn(...) + this.addChild(name, ...) in one call — the idiomatic way to compose entity trees (logical root + visual body

  • UI sibling + …).

Mirrors the overload shape of Scene.spawn: pass an Entity subclass (with optional setup params), a Blueprint, or omit for an anonymous base Entity.

this.spawnChild("body", EnemyBody, { color: 0xff6b6b });
this.spawnChild("hp", EnemyHealthBar);

string

SpawnOptions

Entity

Entity.spawnChild

spawnChild<E>(name, Class, …rest): E

Defined in: core/dist/index.d.ts:469

Spawn a new entity in this entity’s scene and add it as a named child. Combines scene.spawn(...) + this.addChild(name, ...) in one call — the idiomatic way to compose entity trees (logical root + visual body

  • UI sibling + …).

Mirrors the overload shape of Scene.spawn: pass an Entity subclass (with optional setup params), a Blueprint, or omit for an anonymous base Entity.

this.spawnChild("body", EnemyBody, { color: 0xff6b6b });
this.spawnChild("hp", EnemyHealthBar);

E extends Entity

string

() => E

ClassSpawnArgs<E>

E

Entity.spawnChild

spawnChild<P>(name, blueprint, params, options?): Entity

Defined in: core/dist/index.d.ts:470

Spawn a new entity in this entity’s scene and add it as a named child. Combines scene.spawn(...) + this.addChild(name, ...) in one call — the idiomatic way to compose entity trees (logical root + visual body

  • UI sibling + …).

Mirrors the overload shape of Scene.spawn: pass an Entity subclass (with optional setup params), a Blueprint, or omit for an anonymous base Entity.

this.spawnChild("body", EnemyBody, { color: 0xff6b6b });
this.spawnChild("hp", EnemyHealthBar);

P

string

Blueprint<P>

P

SpawnOptions

Entity

Entity.spawnChild

spawnChild(name, blueprint, options?): Entity

Defined in: core/dist/index.d.ts:471

Spawn a new entity in this entity’s scene and add it as a named child. Combines scene.spawn(...) + this.addChild(name, ...) in one call — the idiomatic way to compose entity trees (logical root + visual body

  • UI sibling + …).

Mirrors the overload shape of Scene.spawn: pass an Entity subclass (with optional setup params), a Blueprint, or omit for an anonymous base Entity.

this.spawnChild("body", EnemyBody, { color: 0xff6b6b });
this.spawnChild("hp", EnemyHealthBar);

string

Blueprint<void>

SpawnOptions

Entity

Entity.spawnChild


tryGet<C>(cls): C | undefined

Defined in: core/dist/index.d.ts:483

Get a component by class, or undefined if not found.

C extends Component

ComponentClass<C>

C | undefined

Entity.tryGet


tryGetChild(name): Entity | undefined

Defined in: core/dist/index.d.ts:477

Get a child by name, or undefined if not found.

string

Entity | undefined

Entity.tryGetChild