Entities · interface

ComponentType

Explained in Entities.

interface ComponentType
import type { ComponentType } from '@driftengine/entities';

Properties

NameTypeDescription
namereadonlystring
schemareadonlySchema
idreadonlynumberA small dense integer, for indexing by component type in a query or a schedule.
More

Allocated in declaration order at module load, so it is the same on every run of the same code — and it is deliberately not what a scene is written with. A scene uses field ids, which survive a reorder; this survives nothing and is never stored.

entityFieldsreadonlyreadonly string[]Fields typed Entity, which a scene load has to rewrite through its id map.
defaultsreadonlyReadonly<Record<string, ComponentDefault>>The value each field was declared with, by field name; a field with none is absent and starts at zero, false or nothing.
More

Read wherever a field is not given: an entity added with some of its fields, a prefab that names a few, a saved scene from before the field existed. A DriftScript component's come from the module's metadata (seed: u32 = 7); before they were read, every one of those paths filled zero and nothing said so.