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

    Function create

    • Declares a system and returns it; nothing runs. The arguments tell the forms apart:

      • create(body): a system that declares nothing, whose body runs once per run with its resources and commands.
      • create(declaration, body): a system.
      • create([move, collide]): a composite of the systems listed, which may live on different threads.
      • create({ systems: [move, collide], after: [input] }): a composite with constraints.

      What a body reads, writes and reduces into the build infers from it. Each run passes a composite's members one input, with every field of theirs. Throws if a system names a key that isn't registered as its kind, its body writes a reference, a lookup's rows are read where it writes them or it goes through an index keyed by what it writes, its rows are ordered by an index it isn't sorted or keyed by what it writes, its object components and resources live on different threads, or its reductions, conditions, up, order or placement can't hold, or it's an observer and writes, reduces, takes input, is a kernel, has up or is ordered; if the build couldn't follow how its body uses its resources, lookups or parent; or if a composite's member isn't a system a constructor returned, or two members declare an input field with different schemas. A composite's observer members run after its sync point, ordered with nothing.

      A run of a system without components resolves to what its body returns, or undefined when its conditions, resource change filters or index lookups' changed: true skip it; a run of any other system or a composite to nothing. A body returns no promise, by type and at runtime, where returning one fails its system: a run never waits for one.

      One argument, a body or a composite, is one overload, so a mistake in it is reported where it is rather than as no overload matching.

      Type Parameters

      • const D extends Declaration
      • B extends
            | (
                (
                    row: Row<{ components: object } & Declaration>,
                    context: Context<{ components: object } & Declaration>,
                    input: never,
                ) => void
            )
            | ((context: Context<Declaration>, input: never) => void)

      Parameters

      • declaration: D & LookupChanges<D> & Where<D> & Conditions<D> & Inferred & (
            D extends { kernel: "gpu" } ? GpuKernel : {}
        ) & (
            Property<D, "components"> extends undefined
                ? {
                    kernel?:
                        | false
                        | {
                            "error: a system without components runs once, so there's nothing to compile": true;
                        };
                    order?: {
                        "error: a system without components runs once, in no order": true;
                    };
                    up?: { readonly [key: string]: never };
                }
                : {}
        ) & (
            D extends { up: object }
                ? {
                    order?: {
                        "error: up and order both decide the order of its rows": true;
                    };
                }
                : {}
        ) & (
            D extends { components: { optional: readonly [unknown, unknown] } }
                ? {
                    kernel?:
                        | boolean
                        | { "error: a GPU kernel can't have optional components yet": true };
                }
                : {}
        ) & (D extends { observer: true } ? Observer : {}) & (
            D extends { target: string } ? Targeted : {}
        ) & (
            D extends { target: string }
                ? Property<D<D>, "components"> extends undefined
                    ? {
                        target?: {
                            "error: a system on one entity runs on its row, so it needs components": true;
                        };
                    }
                    : {}
                : {}
        ) & { input?: undefined; shader?: undefined } & Placed<D>
      • body: B & Checks<D, InputOf<D, B>> & ReturnsNoPromise<B>

      Returns System<InputOf<D, B>, ResultOf<D, B>>

    • Declares a system and returns it; nothing runs. The arguments tell the forms apart:

      • create(body): a system that declares nothing, whose body runs once per run with its resources and commands.
      • create(declaration, body): a system.
      • create([move, collide]): a composite of the systems listed, which may live on different threads.
      • create({ systems: [move, collide], after: [input] }): a composite with constraints.

      What a body reads, writes and reduces into the build infers from it. Each run passes a composite's members one input, with every field of theirs. Throws if a system names a key that isn't registered as its kind, its body writes a reference, a lookup's rows are read where it writes them or it goes through an index keyed by what it writes, its rows are ordered by an index it isn't sorted or keyed by what it writes, its object components and resources live on different threads, or its reductions, conditions, up, order or placement can't hold, or it's an observer and writes, reduces, takes input, is a kernel, has up or is ordered; if the build couldn't follow how its body uses its resources, lookups or parent; or if a composite's member isn't a system a constructor returned, or two members declare an input field with different schemas. A composite's observer members run after its sync point, ordered with nothing.

      A run of a system without components resolves to what its body returns, or undefined when its conditions, resource change filters or index lookups' changed: true skip it; a run of any other system or a composite to nothing. A body returns no promise, by type and at runtime, where returning one fails its system: a run never waits for one.

      One argument, a body or a composite, is one overload, so a mistake in it is reported where it is rather than as no overload matching.

      Type Parameters

      • const C extends Composition | Alone

      Parameters

      • only: C & Checked<C>

      Returns C extends (context: Context<{}>) => R
          ? System<undefined, R>
          : System<CompositeInputOf<MembersOf<C>>>