ComponentInfo

View source

Represents registration metadata associated with one component type.

The ECS uses this value to retain the component’s identity and lifecycle-hook configuration while the type is registered. Configure hooks through World#setComponentHooks or App#setComponentHooks; most API users inspect rather than construct ComponentInfo values.

Constructor


constructor(id: number, name: string)

View source

Creates metadata for a registered component type.

The constructor stores id and name as supplied. Constructing one does not register a component with a World or install its hooks; the new value starts with an empty ComponentHooks configuration.

Parameters

NameDescriptionDefault
id

Numeric identifier assigned during registration.

—
name

Component type name or type ID.

—

Properties


readonlyid: number

View source

Numeric identifier assigned to this component during registration.

Component IDs are dense, zero-based values assigned in registration order. This metadata identifier is distinct from the component type’s string name or type ID.

Default: 0

readonlyname: string

View source

String type name or type ID associated with this component.

The value is stored exactly as supplied; this class does not derive, validate, or normalize it.

Methods


getHooks(): ComponentHooks

View source

Returns this component’s current lifecycle hooks.

The stored ComponentHooks object is returned directly, not copied. Changes to that object are visible to the world using this metadata.

Returns

The hooks currently associated with the component.

setHooks(hooks: ComponentHooks): void

View source

Replaces this component’s lifecycle hooks.

The replacement is stored as-is; existing callbacks are not merged with it. Most API users should use World#setComponentHooks or App#setComponentHooks to configure component hooks.

Parameters

NameDescriptionDefault
hooks

New lifecycle hooks for the component.

—