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 });Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new TimerEntity(
name?,tags?):TimerEntity
Defined in: Entity.ts:57
Parameters
Section titled “Parameters”string
Iterable<string, any, any>
Returns
Section titled “Returns”TimerEntity
Inherited from
Section titled “Inherited from”Properties
Section titled “Properties”
readonlyid:number
Defined in: Entity.ts:36
Unique auto-incrementing ID.
Inherited from
Section titled “Inherited from”
readonlyoptionalkey?:string
Defined in: Entity.ts:47
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").
Inherited from
Section titled “Inherited from”
readonlyname:string
Defined in: Entity.ts:38
Display name for debugging.
Inherited from
Section titled “Inherited from”
readonlytags:Set<string>
Defined in: Entity.ts:40
Tags for group queries.
Inherited from
Section titled “Inherited from”[TRAITS_KEY]
Section titled “[TRAITS_KEY]”
static[TRAITS_KEY]:Set<symbol>
Defined in: Entity.ts:34
Inherited from
Section titled “Inherited from”Accessors
Section titled “Accessors”children
Section titled “children”Get Signature
Section titled “Get Signature”get children():
ReadonlyMap<string,Entity>
Defined in: Entity.ts:99
Named children as a read-only map. Empty map if no children.
Returns
Section titled “Returns”ReadonlyMap<string, Entity>
Inherited from
Section titled “Inherited from”isDestroyed
Section titled “isDestroyed”Get Signature
Section titled “Get Signature”get isDestroyed():
boolean
Defined in: Entity.ts:89
True if destroy() has been called.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”parent
Section titled “parent”Get Signature
Section titled “Get Signature”get parent():
Entity|null
Defined in: Entity.ts:94
The parent entity, or null if this is a root entity.
Returns
Section titled “Returns”Entity | null
Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get scene():
Scene
Defined in: Entity.ts:74
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 destroy() tears it down. Inside
lifecycle methods (setup, component onAdd, update, etc.) 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.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”tryScene
Section titled “tryScene”Get Signature
Section titled “Get Signature”get tryScene():
Scene|null
Defined in: Entity.ts:84
The scene this entity belongs to, or null if detached.
Returns
Section titled “Returns”Scene | null
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”_performDestroy()
Section titled “_performDestroy()”_performDestroy():
void
Defined in: Entity.ts:346
Internal
Internal: perform actual destruction — remove all components and clear state. Called by Scene during endOfFrame flush.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”_setKey()
Section titled “_setKey()”_setKey(
key):void
Defined in: Entity.ts:430
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.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”_setScene()
Section titled “_setScene()”_setScene(
scene,callbacks):void
Defined in: Entity.ts:416
Internal
Internal: set the scene and callbacks. Called by Scene.spawn().
Parameters
Section titled “Parameters”Scene | null
callbacks
Section titled “callbacks”EntityCallbacks | null
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”add<
C>(component):C
Defined in: Entity.ts:242
Add a component instance. Returns the component for chaining.
Type Parameters
Section titled “Type Parameters”C extends Component
Parameters
Section titled “Parameters”component
Section titled “component”C
Returns
Section titled “Returns”C
Inherited from
Section titled “Inherited from”addChild()
Section titled “addChild()”addChild(
name,child):void
Defined in: Entity.ts:104
Add a named child entity. Auto-adds to parent’s scene if not already in one.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”afterRestore()?
Section titled “afterRestore()?”
optionalafterRestore(data,resolve):void
Defined in: Entity.ts:382
Called after components are restored during save/load. Rebuild non-serializable state here.
Parameters
Section titled “Parameters”unknown
resolve
Section titled “resolve”Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”cancel()
Section titled “cancel()”cancel(
tag?):void
Defined in: TimerEntity.ts:32
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
destroy()
Section titled “destroy()”destroy():
void
Defined in: Entity.ts:327
Mark for deferred destruction. Actual cleanup happens at end of frame.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”emit()
Section titled “emit()”Call Signature
Section titled “Call Signature”emit(
token):void
Defined in: Entity.ts:304
Emit a typed event on this entity. Bubbles to the scene.
Parameters
Section titled “Parameters”EventToken<void>
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”emit<
T>(token,data):void
Defined in: Entity.ts:305
Emit a typed event on this entity. Bubbles to the scene.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”EventToken<T>
T
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”get<
C>(cls):C
Defined in: Entity.ts:257
Get a component by class. Throws if not found.
Type Parameters
Section titled “Type Parameters”C extends Component
Parameters
Section titled “Parameters”Returns
Section titled “Returns”C
Inherited from
Section titled “Inherited from”getAll()
Section titled “getAll()”getAll():
Iterable<Component>
Defined in: Entity.ts:322
Get all components as an iterable.
Returns
Section titled “Returns”Iterable<Component>
Inherited from
Section titled “Inherited from”getChild()
Section titled “getChild()”getChild(
name):Entity
Defined in: Entity.ts:228
Get a child by name. Throws if not found.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”has(
cls):boolean
Defined in: Entity.ts:273
Check if entity has a component of the given class.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”hasTrait()
Section titled “hasTrait()”hasTrait<
T>(token):this is TimerEntity & T
Defined in: Entity.ts:385
Check if this entity’s class implements a given trait. Acts as a type guard.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”TraitToken<T>
Returns
Section titled “Returns”this is TimerEntity & T
Inherited from
Section titled “Inherited from”on<
T>(token,handler): () =>void
Defined in: Entity.ts:289
Subscribe to a typed event on this entity. Returns an unsubscribe function.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”EventToken<T>
handler
Section titled “handler”(data) => void
Returns
Section titled “Returns”() => void
Inherited from
Section titled “Inherited from”remove()
Section titled “remove()”remove(
cls):void
Defined in: Entity.ts:278
Remove a component by class.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”removeChild()
Section titled “removeChild()”removeChild(
name):Entity
Defined in: Entity.ts:213
Remove a named child. Returns the detached entity.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”requireKey()
Section titled “requireKey()”requireKey():
string
Defined in: Entity.ts:402
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).
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”run(
process,options?):Process
Defined in: TimerEntity.ts:24
Parameters
Section titled “Parameters”process
Section titled “process”options?
Section titled “options?”string[]
Returns
Section titled “Returns”serialize()?
Section titled “serialize()?”
optionalserialize():unknown
Defined in: Entity.ts:379
Return a JSON-serializable snapshot of this entity’s custom state. Used by the save system.
Returns
Section titled “Returns”unknown
Inherited from
Section titled “Inherited from”setup()
Section titled “setup()”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.
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”slot()
Section titled “slot()”slot(
config?):ProcessSlot
Defined in: TimerEntity.ts:28
Parameters
Section titled “Parameters”config?
Section titled “config?”Returns
Section titled “Returns”spawnChild()
Section titled “spawnChild()”Call Signature
Section titled “Call Signature”spawnChild(
name,options?):Entity
Defined in: Entity.ts:146
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);Parameters
Section titled “Parameters”string
options?
Section titled “options?”Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”spawnChild<
E>(name,Class,options?):E
Defined in: Entity.ts:147
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);Type Parameters
Section titled “Type Parameters”E extends Entity
Parameters
Section titled “Parameters”string
() => E
options?
Section titled “options?”Returns
Section titled “Returns”E
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”spawnChild<
E,P>(name,Class,params,options?):E
Defined in: Entity.ts:152
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);Type Parameters
Section titled “Type Parameters”E extends Entity
P
Parameters
Section titled “Parameters”string
() => E & object
params
Section titled “params”P
options?
Section titled “options?”Returns
Section titled “Returns”E
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”spawnChild<
P>(name,blueprint,params,options?):Entity
Defined in: Entity.ts:158
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);Type Parameters
Section titled “Type Parameters”P
Parameters
Section titled “Parameters”string
blueprint
Section titled “blueprint”Blueprint<P>
params
Section titled “params”P
options?
Section titled “options?”Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”spawnChild(
name,blueprint,options?):Entity
Defined in: Entity.ts:165
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);Parameters
Section titled “Parameters”string
blueprint
Section titled “blueprint”Blueprint<void>
options?
Section titled “options?”Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”tryGet()
Section titled “tryGet()”tryGet<
C>(cls):C|undefined
Defined in: Entity.ts:268
Get a component by class, or undefined if not found.
Type Parameters
Section titled “Type Parameters”C extends Component
Parameters
Section titled “Parameters”Returns
Section titled “Returns”C | undefined
Inherited from
Section titled “Inherited from”tryGetChild()
Section titled “tryGetChild()”tryGetChild(
name):Entity|undefined
Defined in: Entity.ts:237
Get a child by name, or undefined if not found.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Entity | undefined