Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • ECS

Index

Properties

components

components: {}

Type declaration

registry

registry: Registry = new Registry()

Private updateSystems

updateSystems: (() => void)[] = []

Private viewCache

viewCache: Map<string, CachedView> = new Map()

Methods

Private _getComponentParamNames

  • _getComponentParamNames(func: any): any
  • Crimes are committed here

    Parameters

    • func: any

      Function to extract component names from

    Returns any

addAssignSystem

  • addAssignSystem<T>(components: any, f: (cmpts: T, e?: Entity) => void): void
  • Type parameters

    • T

    Parameters

    • components: any
    • f: (cmpts: T, e?: Entity) => void
        • (cmpts: T, e?: Entity): void
        • Parameters

          Returns void

    Returns void

addRemoveSystem

  • addRemoveSystem<T>(components: any, f: (cmpts: T, e?: Entity) => void): void
  • Type parameters

    • T

    Parameters

    • components: any
    • f: (cmpts: T, e?: Entity) => void
        • (cmpts: T, e?: Entity): void
        • Parameters

          Returns void

    Returns void

addUpdateSystem

  • addUpdateSystem<T>(components: any, f: (cmpts: T, e?: Entity) => void): void
  • Type parameters

    • T

    Parameters

    • components: any
    • f: (cmpts: T, e?: Entity) => void
        • (cmpts: T, e?: Entity): void
        • Parameters

          Returns void

    Returns void

assign

  • assign(e: Entity, name: string, cmpt: any): void
  • Assign the component value cmpt to entity e with the name name

    Parameters

    • e: Entity

      The entity

    • name: string

      The name of the component

    • cmpt: any

      The value of the component

    Returns void

component

  • Returns a ComponentStore for the component named name

    If a store for a component named name does not already exist one is created

    Parameters

    • name: string

      The name of the component

    Returns ComponentStore

create

  • create(spec: any): number
  • Create a new entity and assign it components according to spec

    Any onassign functions associated with components in spec will fire. The order they fire in is undefined.

    Parameters

    • spec: any

      an object describing the components to assign to the new entity

    Returns number

    The newly created [[Entity]]

destroy

  • destroy(entity: Entity): void
  • Remove all components assigned to entity and remove it from registry

    Any onremove functions associated with components on entity will fire. The order they fire in is undefined.

    Parameters

    • entity: Entity

      Entity to destroy

    Returns void

destroyAll

  • destroyAll(): void
  • Calls destroy on every entity

    Component on every entity will have its onremove system fire. The order they fire in is undefined.

    Returns void

Private getCachedView

getComponent

  • getComponent(e: Entity, name: string): any
  • Returns the value of the component named name assigned to entity e

    Parameters

    • e: Entity

      The entity

    • name: string

      The name of the component

    Returns any

getComponents

  • getComponents(e: Entity): {}
  • Returns a JavaScript object of every component assigned to entity e

    remarks

    This is not a fast operation. The resulting object is not stored or used by the ECS -- it is computed every time this method is called.

    Parameters

    Returns {}

hasComponent

  • hasComponent(e: any, name: any): boolean
  • Tests if the entity e has the a component named name

    Parameters

    • e: any

      The entity

    • name: any

      The name of the component

    Returns boolean

Private newCachedView

  • Constructs a fast view of components

    Allows for rapid iteration over entites that have all every component in components.

    Parameters

    • components: (string | ComponentStore)[]

      The stores or names of the components

    Returns CachedView

onassign

  • onassign<T>(f: (cmpts: T, e?: Entity) => void): void
  • Type parameters

    • T

    Parameters

    • f: (cmpts: T, e?: Entity) => void
        • (cmpts: T, e?: Entity): void
        • Parameters

          Returns void

    Returns void

onremove

  • onremove<T>(f: (cmpts: T, e?: Entity) => void): void
  • associate removal logic with entities

    sugar

    the names of the parameters will be used

    Type parameters

    • T

    Parameters

    • f: (cmpts: T, e?: Entity) => void

      The function

        • (cmpts: T, e?: Entity): void
        • Parameters

          • cmpts: T

            a

          • Optional e: Entity

            b

          Returns void

    Returns void

onupdate

  • onupdate<T>(system: (cmpts: T, e?: Entity) => void): void
  • Associate update systems with components matching the arguments to system

    This function will run once every time update is called on every active entity that has components with names matching the argument names to system. Update systems are run in the order they are attached. The order of entities within a particular system is undefined.

    Type parameters

    • T

    Parameters

    • system: (cmpts: T, e?: Entity) => void

      The update system

        • (cmpts: T, e?: Entity): void
        • Parameters

          Returns void

    Returns void

remove

  • remove(e: Entity, name: string): void
  • Remove the component named name from the entity e

    Any destroy logic associated with name will be invoked.

    Parameters

    • e: Entity

      The entity

    • name: string

      The name of the component

    Returns void

update

  • update(): void
  • Run all update systems

    Returns void

Private view

  • Constructs a View of components.

    Not sure why you would use this over the faster CachedView, might be obsolete.

    Parameters

    • components: (string | ComponentStore)[]

      The stores or names of the components

    Returns View

Legend

  • Constructor
  • Property
  • Method
  • Private property
  • Private method

Generated using TypeDoc