Skip to content

TimerEntity

Defined in: TimerEntity.ts:17

A pre-built entity that exposes the ProcessComponent API directly. Useful for scene-level timing without manual component wiring.

const timers = this.spawn(TimerEntity);
timers.run(Process.delay(500, () => { ... }));
const cd = timers.slot({ duration: 300 });

new TimerEntity(name?, tags?): TimerEntity

Defined in: Entity.ts:48

string

Iterable<string, any, any>

TimerEntity

Entity.constructor

readonly id: number

Defined in: Entity.ts:34

Unique auto-incrementing ID.

Entity.id


readonly name: string

Defined in: Entity.ts:36

Display name for debugging.

Entity.name


readonly tags: Set<string>

Defined in: Entity.ts:38

Tags for group queries.

Entity.tags


static [TRAITS_KEY]: Set<symbol>

Defined in: Entity.ts:32

Entity.[TRAITS_KEY]

get children(): ReadonlyMap<string, Entity>

Defined in: Entity.ts:70

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

ReadonlyMap<string, Entity>

Entity.children


get isDestroyed(): boolean

Defined in: Entity.ts:60

True if destroy() has been called.

boolean

Entity.isDestroyed


get parent(): Entity | null

Defined in: Entity.ts:65

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

Entity | null

Entity.parent


get scene(): Scene | null

Defined in: Entity.ts:55

The scene this entity belongs to, or null.

Scene | null

Entity.scene

_performDestroy(): void

Defined in: Entity.ts:235

Internal

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

void

Entity._performDestroy


_setScene(scene, callbacks): void

Defined in: Entity.ts:290

Internal

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

Scene | null

EntityCallbacks | null

void

Entity._setScene


add<C>(component): C

Defined in: Entity.ts:132

Add a component instance. Returns the component for chaining.

C extends Component

C

C

Entity.add


addChild(name, child): void

Defined in: Entity.ts:75

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: Entity.ts:271

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

unknown

SnapshotResolver

void

Entity.afterRestore


cancel(tag?): void

Defined in: TimerEntity.ts:32

string

void


destroy(): void

Defined in: Entity.ts:216

Mark for deferred destruction. Actual cleanup happens at end of frame.

void

Entity.destroy


emit(token): void

Defined in: Entity.ts:194

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

EventToken<void>

void

Entity.emit

emit<T>(token, data): void

Defined in: Entity.ts:195

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

T

EventToken<T>

T

void

Entity.emit


get<C>(cls): C

Defined in: Entity.ts:147

Get a component by class. Throws if not found.

C extends Component

ComponentClass<C>

C

Entity.get


getAll(): Iterable<Component>

Defined in: Entity.ts:211

Get all components as an iterable.

Iterable<Component>

Entity.getAll


getChild(name): Entity

Defined in: Entity.ts:118

Get a child by name. Throws if not found.

string

Entity

Entity.getChild


has(cls): boolean

Defined in: Entity.ts:163

Check if entity has a component of the given class.

ComponentClass

boolean

Entity.has


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

Defined in: Entity.ts:274

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

T

TraitToken<T>

this is TimerEntity & T

Entity.hasTrait


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

Defined in: Entity.ts:179

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

T

EventToken<T>

(data) => void

() => void

Entity.on


remove(cls): void

Defined in: Entity.ts:168

Remove a component by class.

ComponentClass

void

Entity.remove


removeChild(name): Entity

Defined in: Entity.ts:103

Remove a named child. Returns the detached entity.

string

Entity

Entity.removeChild


run(process, options?): Process

Defined in: TimerEntity.ts:24

Process

string[]

Process


optional serialize(): unknown

Defined in: Entity.ts:268

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

unknown

Entity.serialize


setup(): void

Defined in: TimerEntity.ts:20

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.

void

Entity.setup


slot(config?): ProcessSlot

Defined in: TimerEntity.ts:28

ProcessSlotConfig

ProcessSlot


tryGet<C>(cls): C | undefined

Defined in: Entity.ts:158

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: Entity.ts:127

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

string

Entity | undefined

Entity.tryGetChild