@adobe/ecs - v0.2.1
    Preparing search index...

    Type Alias Commands

    Structural changes and writes to other entities, applied in issue order at the next sync point. They take only the components commands may add: every one but those rules derive.

    type Commands = {
        add<K extends never>(
            entity: Entity,
            component: K,
            ...value: ValueArgument<K>,
        ): void;
        add<const C extends readonly never[]>(
            entity: Entity,
            components: C,
            values: ValuesOf<C>,
        ): void;
        despawn(entity: Entity): void;
        remove(entity: Entity, component: never): void;
        remove(entity: Entity, components: readonly never[]): void;
        spawn<const C extends readonly never[], const P extends Preset<C> = {}>(
            components: Spawned<C, P>,
            ...constant: RequiresPreset<C> extends true
                ? [constant?: P & SharedPreset<C> & Named<C, P>]
                : [constant?: P & Named<C, P>],
        ): (...values: SpawnValues<C, P>) => Entity;
    }
    Index

    Methods

    • Adds or replaces one component's value, marking it changed.

      Type Parameters

      • K extends never

      Parameters

      • entity: Entity
      • component: K
      • ...value: ValueArgument<K>

      Returns void

    • Adds or replaces the values of components, marking them changed.

      Type Parameters

      • const C extends readonly never[]

      Parameters

      • entity: Entity
      • components: C
      • values: ValuesOf<C>

      Returns void

    • The spawner of entities of exactly components: on the world's thread, the same function for a world, list and equal constants each time while an archetype holds each shared value among them, so calling it allocates nothing; on a joined thread, the same for a list and one constants object, found by its identity. constant gives values every entity it spawns starts with: each shared component's, which the spawner must be given, since they choose the archetype, and any other's. Its call takes the rest, or nothing once none of them is required, each component's value from one of the two, never both, which fails the system; it returns a real entity immediately, alive at the sync point.

      Type Parameters

      • const C extends readonly never[]
      • const P extends Preset<C> = {}

      Parameters

      • components: Spawned<C, P>
      • ...constant: RequiresPreset<C> extends true
            ? [constant?: P & SharedPreset<C> & Named<C, P>]
            : [constant?: P & Named<C, P>]

      Returns (...values: SpawnValues<C, P>) => Entity