Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @gdgt/ecs

Index

Type Aliases

ComponentDeclaration<T>: [symbol, (() => T)]

Type Parameters

  • T = object

QueryResult<P>: (P extends { trackAdded: true } ? { added: Set<Entity> } : object) & (P extends { trackRemoved: true } ? { removed: Set<Entity> } : object) & (P extends { trackMutated: ComponentDeclaration[] } ? { mutated: Set<Entity> } : object) & { entities: Set<Entity> }

The result returned when you call Query.collect, consisting of multiple Sets of Entitys:

  • entities contains all entities matching the query at the time Query.collect was called.

  • added is only present if the query was constructed with trackAdded: true and contains all entities newly matching the query, since the last time Query.collect was called.

  • removed is only present if the query was constructed with trackRemoved: true and contains all entities no longer matching the query, since the last time Query.collect was called.

  • mutated is only present if the query was constructed with the QueryProps.trackMutated option and contains all entities with changes to any of the components listed in QueryProps.trackMutated, since the last time Query.collect was called.

example

The result of a Query with all tracking options enabled looks like this:

{
entities: Set<Entity>,
added: Set<Entity>,
removed: Set<Entity>,
mutated: Set<Entity>,
}

Type Parameters

Functions

  • Declares a new component.

    Type Parameters

    • T = unknown

    Parameters

    • defaultValueFactory: (() => T)

      A function returning the components default value. This is the value the component has when added to an Entity.

        • (): T
        • Returns T

    Returns ComponentDeclaration<T>

    The component declaration.

  • Declares a new component.

    Type Parameters

    • T = unknown

    Parameters

    • identifier: string | symbol

      A unique identifier. If a string is provided, you'll need to ensure that it is unique manually.

    • defaultValueFactory: (() => T)

      A function returning the components default value. This is the value the component has when added to an Entity.

        • (): T
        • Returns T

    Returns ComponentDeclaration<T>

    The component declaration.

Variables

defaultWorld: World = ...

Generated using TypeDoc