Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Ecs<M>

Type parameters

  • M

Hierarchy

  • Ecs

Constructors

constructor

  • Glues an EntityPool with ComponentManagers.

    Parameters

    Returns Ecs

Properties

componentManagers

componentManagers: ComponentManagerMap<M>

The Map of componentManagers to use.

pool

Entity pool used to generate entities.

Methods

createEntity

  • Generates an entity id, registers the passed components.

    Parameters

    • Default value components: Partial<ExtractComponentMap<M>> = {}

      The components the entity should have.

    Returns number

    The entity id.

deleteEntity

  • deleteEntity(id: number): void
  • Deletes and entity by id.

    Parameters

    • id: number

      The id of the enity to delete.

    Returns void

getComponentsByEntityId

  • getComponentsByEntityId<L>(id: number, components: L): object
  • Gets a few components for a given id.

    Type parameters

    • L: ReadonlyArray<keyof M>

    Parameters

    • id: number

      The id of the entity to get components from.

    • components: L

      List with what components to get.

    Returns object

getEntityById

  • getEntityById<L>(id: number): L
  • Gets all components of the entity with the given id.

    Note: If you only want to get a few of the components, use the getComponentsByEntityId method instead.

    Type parameters

    Parameters

    • id: number

      The id of the entity.

    Returns L

Generated using TypeDoc