ecspresso
    Preparing search index...

    Class default<Cfg, Labels, Groups, AssetGroupNames, ReactiveQueryNames>

    ECSpresso is the central ECS framework class that connects all features. It handles creation and management of entities, components, and systems, and provides lifecycle hooks.

    Type Parameters

    • Cfg extends WorldConfig = EmptyConfig
    • Labels extends string = string
    • Groups extends string = string
    • AssetGroupNames extends string = string
    • ReactiveQueryNames extends string = string
    Index

    Constructors

    Properties

    _cfg: Cfg
    VERSION: string = version

    Library version

    Accessors

    • get changeThreshold(): number

      The current change detection threshold. During system execution, this is the system's last-seen sequence. Between updates, this is the global sequence after command buffer playback. Manual change detection should compare: getChangeSeq(...) > changeThreshold

      Returns number

    • get commands(): CommandBuffer<Cfg>

      Command buffer for queuing deferred structural changes. Commands are executed automatically at the end of each update() cycle.

      Returns CommandBuffer<Cfg>

      // In a system or event handler
      ecs.commands.removeEntity(entityId);
      ecs.commands.spawn({ position: { x: 0, y: 0 } });
    • get currentTick(): number

      The current tick number, incremented at the end of each update()

      Returns number

    • get entityManager(): EntityManager<Cfg["components"]>

      Returns EntityManager<Cfg["components"]>

    • get fixedDt(): number

      The configured fixed timestep interval in seconds.

      Returns number

    • get installedPlugins(): string[]

      Get all installed plugin IDs

      Returns string[]

    • get interpolationAlpha(): number

      The interpolation alpha between fixed update steps. Ranges from 0 to <1, representing how far into the next fixed step the current frame is. Use in the render phase for smooth visual interpolation.

      Returns number

    • get systemTimings(): ReadonlyMap<string, number>

      Returns ReadonlyMap<string, number>

    Methods

    • Add or replace a component on an entity. Triggers component-added callbacks and marks the component as changed.

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • entityId: number

        The entity ID

      • componentName: K

        The component to add

      • value: Cfg["components"][K]

        The component value

      Returns void

    • Add multiple components to an entity at once.

      Type Parameters

      • T extends { [K in string | number | symbol]?: Cfg["components"][K] }

      Parameters

      • entityId: number

        The entity ID

      • components: T & Record<Exclude<keyof T, keyof Cfg["components"]>, never>

        Object with component names as keys and component data as values

      Returns void

    • Add a resource to the ECS instance.

      • Plain value → stored directly
      • Function → treated as a factory, called with this ECSpresso instance on first access
      • { factory, dependsOn?, onDispose? } → factory with dependencies/disposal
      • directValue(val) → stores the value as-is (use to store functions/classes without invoking them)

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • key: K
      • resource:
            | Cfg["resources"][K]
            | (
                (
                    ecs: default<Cfg>,
                ) => Cfg["resources"][K] | Promise<Cfg["resources"][K]>
            )
            | ResourceFactoryWithDeps<
                Cfg["resources"][K],
                default<Cfg, string, string, string, string>,
                keyof Cfg["resources"] & string,
            >
            | ResourceDirectValue<Cfg["resources"][K]>

      Returns this

    • Adds a system directly to this ECSpresso instance. The system is registered when initialize() or update() is next called.

      Parameters

      • label: string

        Unique name to identify the system

      Returns SystemBuilder<Cfg>

      A SystemBuilder instance for method chaining

    • Disable a system group. Systems in this group will be skipped during update().

      Parameters

      • groupName: Groups

        The name of the group to disable

      Returns void

    • Dispose a single resource, calling its onDispose callback if defined

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • key: K

        The resource key to dispose

      Returns Promise<boolean>

      True if the resource existed and was disposed, false if it didn't exist

    • Dispose all initialized resources in reverse dependency order. Resources that depend on others are disposed first. Calls each resource's onDispose callback if defined.

      Returns Promise<void>

    • Toggle diagnostics timing collection. When enabled, system and phase timings are recorded each frame. When disabled, timing maps are cleared and no overhead is incurred.

      Parameters

      • enabled: boolean

      Returns void

    • Enable a system group. Systems in this group will run during update().

      Parameters

      • groupName: Groups

        The name of the group to enable

      Returns void

    • Traverse the hierarchy in parent-first (breadth-first) order. Parents are guaranteed to be visited before their children.

      Parameters

      • callback: (entityId: number, parentId: number | null, depth: number) => void

        Function called for each entity with (entityId, parentId, depth)

      • Optionaloptions: HierarchyIteratorOptions

        Optional traversal options (roots to filter to specific subtrees)

      Returns void

    • Get all ancestors of an entity in order [parent, grandparent, ...]

      Parameters

      • entityId: number

        The entity ID to get ancestors of

      Returns readonly number[]

      Readonly array of ancestor entity IDs

    • Get a loaded asset by key. Throws if not loaded.

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • key: K

      Returns Cfg["assets"][K]

    • Get a handle to an asset with status information

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • key: K

      Returns AssetHandle<Cfg["assets"][K]>

    • Get a child at a specific index

      Parameters

      • parentId: number

        The parent entity ID

      • index: number

        The index of the child

      Returns number | null

      The child entity ID, or null if index is out of bounds

    • Get the index of a child within its parent's children list

      Parameters

      • parentId: number

        The parent entity ID

      • childId: number

        The child entity ID to find

      Returns number

      The index of the child, or -1 if not found

    • Get all children of an entity in insertion order

      Parameters

      • parentId: number

        The parent entity ID

      Returns readonly number[]

      Readonly array of child entity IDs

    • Get a component value from an entity.

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • entityId: number

        The entity ID

      • componentName: K

        The component to retrieve

      Returns Cfg["components"][K] | undefined

      The component value, or undefined if the entity doesn't have it

    • Get the current screen name

      Returns keyof Cfg["screens"] | null

    • Get all descendants of an entity in depth-first order

      Parameters

      • entityId: number

        The entity ID to get descendants of

      Returns readonly number[]

      Readonly array of descendant entity IDs

    • Get an entity by ID.

      Parameters

      • entityId: number

        The entity ID

      Returns Entity<Cfg["components"]> | undefined

      The entity, or undefined if it doesn't exist

    • Call a helper factory with this world instance, inferring the full world type. Eliminates the need for a separate type ECS = typeof ecs ceremony.

      Type Parameters

      • H

      Parameters

      • factory: (world: this) => H

      Returns H

      const helpers = ecs.getHelpers(createStateMachineHelpers);
      
    • Get the parent of an entity

      Parameters

      • entityId: number

        The entity ID to get the parent of

      Returns number | null

      The parent entity ID, or null if no parent

    • Get a resource by key. Throws if the resource is not found.

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • key: K

        The resource key

      Returns Cfg["resources"][K]

      The resource value

      Error if resource not found

      tryGetResource — the non-throwing alternative that returns undefined

    • Get all resource keys that are currently registered

      Returns (keyof Cfg["resources"])[]

      Array of resource keys

    • Get the root ancestor of an entity (topmost parent), or self if no parent

      Parameters

      • entityId: number

        The entity ID to get the root of

      Returns number

      The root entity ID

    • Get all root entities (entities that have children but no parent)

      Returns readonly number[]

      Readonly array of root entity IDs

    • Get the current screen config (immutable), narrowed to a specific screen. Throws if the current screen doesn't match.

      Type Parameters

      • K extends string

      Parameters

      • screen: K

      Returns Cfg["screens"][K] extends ScreenDefinition<
          C,
          any,
          default<any, string, string, string, string>,
      >
          ? Readonly<C>
          : never

    • Get the current screen config (immutable). Returns a union of all possible config types.

      Returns {
          [K in string | number | symbol]: Cfg["screens"][K] extends ScreenDefinition<
              C,
              any,
              default<any, string, string, string, string>,
          >
              ? Readonly<C>
              : never
      }[keyof Cfg["screens"]]

    • Get the screen stack depth

      Returns number

    • Get the current screen state (mutable), narrowed to a specific screen. Throws if the current screen doesn't match.

      Type Parameters

      • K extends string

      Parameters

      • screen: K

      Returns Cfg["screens"][K] extends ScreenDefinition<
          any,
          S,
          default<any, string, string, string, string>,
      >
          ? S
          : never

    • Get the current screen state (mutable). Returns a union of all possible state types.

      Returns {
          [K in string | number | symbol]: Cfg["screens"][K] extends ScreenDefinition<
              any,
              S,
              default<any, string, string, string, string>,
          >
              ? S
              : never
      }[keyof Cfg["screens"]]

    • Get siblings of an entity (other children of the same parent)

      Parameters

      • entityId: number

        The entity ID to get siblings of

      Returns readonly number[]

      Readonly array of sibling entity IDs

    • Get all system labels that belong to a specific group.

      Parameters

      • groupName: Groups

        The name of the group

      Returns string[]

      Array of system labels in the group

    • Check if an entity has a component

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • entityId: number
      • componentName: K

      Returns boolean

    • Check if a resource exists

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • key: K

      Returns boolean

    • Generator-based hierarchy traversal in parent-first (breadth-first) order. Supports early termination via break.

      Parameters

      Returns Generator<HierarchyEntry, void, unknown>

      HierarchyEntry for each entity in parent-first order

    • Initialize all resources and systems This method:

      1. Initializes all resources that were added as factory functions
      2. Sets up asset manager and loads eager assets
      3. Sets up screen manager
      4. Calls the onInitialize lifecycle hook on all systems

      This is useful for game startup to ensure all resources are ready and systems are properly initialized before the game loop begins.

      Returns Promise<void>

      Promise that resolves when everything is initialized

    • Initialize specific resources or all resources that were added as factory functions but haven't been initialized yet. This is useful when you need to ensure resources are ready before proceeding.

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • ...keys: K[]

        Optional array of resource keys to initialize. If not provided, all pending resources will be initialized.

      Returns Promise<void>

      Promise that resolves when the specified resources are initialized

    • Install a plugin into this ECSpresso instance. Deduplicates by plugin ID. Composite plugins call this in their install function.

      Parameters

      • plugin: Plugin<any, any, any, any, any, any>

      Returns this

    • Check if an entity is an ancestor of another entity

      Parameters

      • entityId: number

        The potential ancestor ID

      • descendantId: number

        The potential descendant ID

      Returns boolean

      true if entityId is an ancestor of descendantId

    • Check if an asset is loaded

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • key: K

      Returns boolean

    • Check if a screen is the current screen

      Parameters

      • screenName: keyof Cfg["screens"]

      Returns boolean

    • Check if an entity is a descendant of another entity

      Parameters

      • entityId: number

        The potential descendant ID

      • ancestorId: number

        The potential ancestor ID

      Returns boolean

      true if entityId is a descendant of ancestorId

    • Check if a screen is active (current or in stack)

      Parameters

      • screenName: keyof Cfg["screens"]

      Returns boolean

    • Check if a system group is enabled.

      Parameters

      • groupName: Groups

        The name of the group to check

      Returns boolean

      true if the group is enabled (or doesn't exist), false if disabled

    • Load a single asset

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • key: K

      Returns Promise<Cfg["assets"][K]>

    • Mark a component as changed on an entity. Each call increments a global monotonic sequence; systems with changed queries will see the mark exactly once (on their next execution).

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • entityId: number

        The entity ID

      • componentName: K

        The component that was changed

      Returns void

    • Mutate a component in place and automatically mark it as changed. Throws if the entity does not exist or does not have the component.

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • entityId: number

        The entity ID

      • componentName: K

        The component to mutate

      • mutator: (value: Cfg["components"][K]) => void

        A function that receives the component value for in-place mutation

      Returns Cfg["components"][K]

      The mutated component value

    • Unsubscribe from an event by callback reference (convenience wrapper for eventBus.unsubscribe)

      Type Parameters

      • E extends string | number | symbol

      Parameters

      • eventType: E

        The event type to unsubscribe from

      • callback: (data: Cfg["events"][E]) => void

        The callback to remove

      Returns boolean

      true if the callback was found and removed, false otherwise

    • Subscribe to an event (convenience wrapper for eventBus.subscribe)

      Type Parameters

      • E extends string | number | symbol

      Parameters

      • eventType: E

        The event type to subscribe to

      • callback: (data: Cfg["events"][E]) => void

        The callback to invoke when the event is published

      Returns () => void

      An unsubscribe function

    • Register a callback when a specific component is added to any entity

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • componentName: K

        The component key

      • handler: (
            ctx: { entity: Entity<Cfg["components"]>; value: Cfg["components"][K] },
        ) => void

        Function receiving the new component value and the entity

      Returns () => void

      Unsubscribe function to remove the callback

    • Register a callback when a specific component is removed from any entity

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • componentName: K

        The component key

      • handler: (
            ctx: { entity: Entity<Cfg["components"]>; value: Cfg["components"][K] },
        ) => void

        Function receiving the old component value and the entity

      Returns () => void

      Unsubscribe function to remove the callback

    • Register a hook that runs after all systems in update()

      Parameters

      • callback: (ctx: { dt: number; ecs: default<Cfg> }) => void

        The hook to call after all systems have processed

      Returns () => void

      An unsubscribe function to remove the hook

    • Subscribe to changes for a specific resource key.

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • key: K

        The resource key to watch

      • callback: (newValue: Cfg["resources"][K], oldValue: Cfg["resources"][K]) => void

        Function called with (newValue, oldValue) when the resource changes

      Returns () => void

      Unsubscribe function

    • Create a plugin factory from the built world's types. Returns a definePlugin equivalent with no manual type parameters.

      Returns <
          PL extends string = never,
          PG extends string = never,
          PAG extends string = never,
          PRQ extends string = never,
      >(
          config: { id: string; install: (world: default<Cfg>) => void },
      ) => Plugin<Cfg, EmptyConfig, PL, PG, PAG, PRQ>

    • Pop the current screen and return to the previous one

      Returns Promise<void>

    • Push a screen onto the stack (overlay)

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • name: K
      • config: Cfg["screens"][K] extends ScreenDefinition<
            C,
            any,
            default<any, string, string, string, string>,
        >
            ? C
            : never

      Returns Promise<void>

    • Register a dispose callback for a component type. Called when a component is removed (explicit removal, entity destruction, or replacement). Later registrations replace earlier ones for the same component type.

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • componentName: K

        The component type to register disposal for

      • callback: (ctx: { entityId: number; value: Cfg["components"][K] }) => void

        Function receiving the component value being disposed and the entity ID

      Returns void

    • Register a required component relationship. When an entity gains trigger, the required component is auto-added (using factory for the default value) if not already present. Enforced at insertion time (spawn/addComponent) only — removal is unrestricted.

      Type Parameters

      • Trigger extends string | number | symbol
      • Required extends string | number | symbol

      Parameters

      • trigger: Trigger

        The component whose presence triggers auto-addition

      • required: Required

        The component to auto-add

      • factory: (triggerValue: Cfg["components"][Trigger]) => Cfg["components"][Required]

        Function that creates the default value for the required component

      Returns void

    • Remove a component from an entity. Triggers component-removed and dispose callbacks.

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • entityId: number

        The entity ID

      • componentName: K

        The component to remove

      Returns void

    • Remove an entity (and optionally its descendants)

      Parameters

      • entityId: number

        Entity ID to remove

      • Optionaloptions: RemoveEntityOptions

        Options for removal (cascade: true by default)

      Returns boolean

      true if entity was removed

    • Remove the parent relationship for an entity (orphan it)

      Parameters

      • childId: number

        The entity ID to orphan

      Returns boolean

      true if a parent was removed, false if entity had no parent

    • Remove a resource from the ECS instance (without calling onDispose)

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • key: K

        The resource key to remove

      Returns boolean

      True if the resource was removed, false if it didn't exist

    • Remove a system by its label Calls the system's onDetach method with this ECSpresso instance if defined

      Parameters

      • label: Labels

        The unique label of the system to remove

      Returns boolean

      true if the system was found and removed, false otherwise

    • Check if a resource needs initialization (was added as a factory function)

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • key: K

        The resource key to check

      Returns boolean

      True if the resource needs initialization

    • Set the parent of an entity

      Parameters

      • childId: number

        The entity ID to set as a child

      • parentId: number

        The entity ID to set as the parent

      Returns this

    • Set a resource to a plain value. Unlike updateResource, does not require an updater function.

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • key: K

        The resource key to set

      • value: Cfg["resources"][K]

        The new resource value

      Returns this

      This ECSpresso instance for chaining

    • Transition to a new screen, clearing the stack

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • name: K
      • config: Cfg["screens"][K] extends ScreenDefinition<
            C,
            any,
            default<any, string, string, string, string>,
        >
            ? C
            : never

      Returns Promise<void>

    • Create an entity and add components to it in one call

      Type Parameters

      • T extends { [K in string | number | symbol]?: Cfg["components"][K] }

      Parameters

      • components: T & Record<Exclude<keyof T, keyof Cfg["components"]>, never>

        Object with component names as keys and component data as values

      Returns FilteredEntity<Cfg["components"], keyof T & keyof Cfg["components"]>

      The created entity with all components added

    • Create an entity as a child of another entity with initial components

      Type Parameters

      • T extends { [K in string | number | symbol]?: Cfg["components"][K] }

      Parameters

      • parentId: number

        The parent entity ID

      • components: T & Record<Exclude<keyof T, keyof Cfg["components"]>, never>

        Initial components to add

      Returns FilteredEntity<Cfg["components"], keyof T & keyof Cfg["components"]>

      The created child entity

    • Get a loaded asset or undefined if not loaded

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • key: K

      Returns Cfg["assets"][K] | undefined

    • Try to get a resource by key. Returns undefined if the resource is not found. Inspired by Bevy's World::get_resource::<T>() which returns Option<&T>.

      Two overloads:

      1. Known key — full type safety from ResourceTypes
      2. String key with explicit type param — for cross-plugin optional dependencies

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • key: K

      Returns Cfg["resources"][K] | undefined

      // Known key (type inferred from ResourceTypes)
      const score = ecs.tryGetResource('score'); // ScoreResource | undefined

      // Cross-plugin optional dependency (caller specifies expected type)
      const si = ecs.tryGetResource<SpatialIndex>('spatialIndex') ?? null;
    • Try to get a resource by key. Returns undefined if the resource is not found. Inspired by Bevy's World::get_resource::<T>() which returns Option<&T>.

      Two overloads:

      1. Known key — full type safety from ResourceTypes
      2. String key with explicit type param — for cross-plugin optional dependencies

      Type Parameters

      • T

      Parameters

      • key: unknown extends T ? never : string

      Returns T | undefined

      // Known key (type inferred from ResourceTypes)
      const score = ecs.tryGetResource('score'); // ScoreResource | undefined

      // Cross-plugin optional dependency (caller specifies expected type)
      const si = ecs.tryGetResource<SpatialIndex>('spatialIndex') ?? null;
    • Get the current screen config narrowed to a specific screen, or undefined if not on that screen.

      Type Parameters

      • K extends string

      Parameters

      • screen: K

      Returns
          | (
              Cfg["screens"][K] extends ScreenDefinition<
                  C,
                  any,
                  default<any, string, string, string, string>,
              >
                  ? Readonly<C>
                  : never
          )
          | undefined

    • Get the current screen config or undefined. Returns a union of all possible config types, or undefined.

      Returns
          | {
              [K in string
              | number
              | symbol]: Cfg["screens"][K] extends ScreenDefinition<
                  C,
                  any,
                  default<any, string, string, string, string>,
              >
                  ? Readonly<C>
                  : never
          }[keyof Cfg["screens"]]
          | undefined

    • Get the current screen state narrowed to a specific screen, or undefined if not on that screen.

      Type Parameters

      • K extends string

      Parameters

      • screen: K

      Returns
          | (
              Cfg["screens"][K] extends ScreenDefinition<
                  any,
                  S,
                  default<any, string, string, string, string>,
              >
                  ? S
                  : never
          )
          | undefined

    • Get the current screen state or undefined. Returns a union of all possible state types, or undefined.

      Returns
          | {
              [K in string
              | number
              | symbol]: Cfg["screens"][K] extends ScreenDefinition<
                  any,
                  S,
                  default<any, string, string, string, string>,
              >
                  ? S
                  : never
          }[keyof Cfg["screens"]]
          | undefined

    • Get the single entity matching a query, or undefined if none match. Throws if more than one entity matches.

      Type Parameters

      • WithComponents extends string | number | symbol
      • WithoutComponents extends string | number | symbol = never

      Parameters

      • withComponents: readonly WithComponents[]

        Components the entity must have

      • withoutComponents: readonly WithoutComponents[] = ...

        Components the entity must not have

      Returns
          | FilteredEntity<
              Cfg["components"],
              WithComponents,
              WithoutComponents,
              never,
          >
          | undefined

      The single matching entity, or undefined if none match

      If more than one entity matches

    • Update all systems across execution phases. Phases run in order: preUpdate -> fixedUpdate -> update -> postUpdate -> render. The fixedUpdate phase uses a time accumulator for deterministic fixed-timestep simulation.

      Parameters

      • deltaTime: number

        Time elapsed since the last update (in seconds)

      Returns void

    • Update an existing resource using an updater function

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • key: K

        The resource key to update

      • updater: (current: Cfg["resources"][K]) => Cfg["resources"][K]

        Function that receives the current resource value and returns the new value

      Returns this

      This ECSpresso instance for chaining

      Error if the resource doesn't exist

    • Update the current screen state, narrowed to a specific screen. Throws if the current screen doesn't match.

      Type Parameters

      • K extends string

      Parameters

      • screen: K
      • update:
            | Partial<
                Cfg["screens"][K] extends ScreenDefinition<
                    any,
                    S,
                    default<any, string, string, string, string>,
                >
                    ? S
                    : never,
            >
            | (
                (
                    current: Cfg["screens"][K] extends ScreenDefinition<
                        any,
                        S,
                        default<any, string, string, string, string>,
                    >
                        ? S
                        : never,
                ) => Partial<
                    Cfg["screens"][K] extends ScreenDefinition<any, infer S> ? S : never,
                >
            )

      Returns void

    • Update the current screen state.

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • update:
            | Partial<
                Cfg["screens"][K] extends ScreenDefinition<
                    any,
                    S,
                    default<any, string, string, string, string>,
                >
                    ? S
                    : never,
            >
            | (
                (
                    current: Cfg["screens"][K] extends ScreenDefinition<
                        any,
                        S,
                        default<any, string, string, string, string>,
                    >
                        ? S
                        : never,
                ) => Partial<
                    Cfg["screens"][K] extends ScreenDefinition<any, infer S> ? S : never,
                >
            )

      Returns void

    • Move a system to a different execution phase at runtime.

      Parameters

      • label: Labels

        The unique label of the system to move

      • phase: SystemPhase

        The target phase

      Returns boolean

      true if the system was found and updated, false otherwise

    • Update the priority of a system

      Parameters

      • label: Labels

        The unique label of the system to update

      • priority: number

        The new priority value (higher values execute first)

      Returns boolean

      true if the system was found and updated, false otherwise

    • Creates a new ECSpresso builder for type-safe plugin installation. Types are inferred from the builder chain — use .withPlugin(), .withComponentTypes<T>(), .withEventTypes<T>(), and .withResource() to accumulate types without manual aggregate interfaces.

      Type Parameters

      Returns ECSpressoBuilder<Cfg2, never, never, never, never>

      A builder instance for fluent method chaining

      const ecs = ECSpresso.create()
      .withPlugin(createRenderer2DPlugin({ ... }))
      .withPlugin(createPhysics2DPlugin())
      .withComponentTypes<{ player: true; enemy: { type: string } }>()
      .withEventTypes<{ gameStart: true }>()
      .withResource('score', { value: 0 })
      .build();

      type ECS = typeof ecs;