@fogrexon/glyph-arena-ecs
Minimal entity-component storage. See also package README.
Exports
Generated from the package's source when the docs are built — do not edit this table by hand.
| Name | Kind |
|---|---|
Entity | type |
World | type |
createWorld | function |
createWorld()
const world = createWorld();
const entity = world.spawn();
world.set(entity, "stats", { hp: 10 });
world.get(entity, "stats");
world.has(entity, "stats");
world.remove(entity, "stats");
world.despawn(entity);
world.dispose();
Methods
spawn()— create an entity. Returns a numericEntityid. Reuses ids from despawned entities.despawn(entity)— remove entity and all components. Missing entities are no-ops.set(entity, key, value)— store a component.undefinedremoves the key. Empty-string keys are ignored. Missing entities are no-ops.get(entity, key)— read a component, orundefinedwhen missing. Empty-string keys returnundefined.has(entity, key)— whether the key exists. Empty-string keys returnfalse.remove(entity, key)— delete a component key. Missing entities or keys are no-ops.dispose()— clear all entities and components. After dispose, all methods are no-ops;spawnreturns ids that cannot store components.
Entity
number — opaque entity id.
Notes
seton the same key overwrites the previous value.- Entities from another world behave like missing entities.
- After
dispose, newly spawned entities are invalid for storage.