Options
All
  • Public
  • Public/Protected
  • All
Menu

Class IndexedComponentManager<T>

Type parameters

  • T

Hierarchy

  • IndexedComponentManager

Implements

Properties

components

components: T[] = new Array<T>()

Array with all components.

emitter

emitter: BitFieldEmitter<number> = new BitFieldEmitter<number>(3)

Standard component manager emitter.

idToIndex

idToIndex: Map<number, number> = new Map<number, number>()

MAp for getting the index of an entity from it's id

indexToId

indexToId: Map<number, number> = new Map<number, number>()

Map for getting the id of an entity from it's index.

Methods

clear

  • clear(): this
  • Do cleanup.

    Returns this

deleteEntity

  • deleteEntity(id: number): this
  • Delete an entity.

    Parameters

    • id: number

      The if of the entity to remove.

    Returns this

get

  • get(id: number): null | T
  • Get the component of an entity by id.

    Parameters

    • id: number

      The id of the entity to get the component of.

    Returns null | T

has

  • has(id: number): boolean
  • Utility method for checking if an id has a registered component.

    Parameters

    • id: number

      THe id of the entity.

    Returns boolean

isEmpty

  • isEmpty(): boolean
  • Utility to get the emptyness of the manager. Usefull for testing.

    Returns boolean

mutateMany

  • mutateMany(ids: number[]): this
  • Mark entities as mutated.

    Parameters

    • ids: number[]

      The ids to emit.

    Returns this

mutateOne

  • mutateOne(id: number): this
  • Mark entity as mutated.

    Parameters

    • id: number

      The id to emit.

    Returns this

registerEntity

  • registerEntity(id: number, component: T): this
  • Add an entity to the manager.

    Parameters

    • id: number

      The id of the entity

    • component: T

      The component to add.

    Returns this

set

  • set(id: number, value: T, mutate?: boolean): this
  • Set the value of an entity knowing it's id.

    Parameters

    • id: number

      The id of the entity.

    • value: T

      The value of the entity.

    • Default value mutate: boolean = true

      If set to true this will automatically emit the changed event.

    Returns this

withMutation

  • withMutation(callback: function): this
  • Runs callback and marks the return value as mutated.

    Parameters

    • callback: function

      The callback to run.

        • (): number
        • Returns number

    Returns this

withMutations

  • withMutations(callback: function): this
  • Runs callback and marks the return value as mutated.

    Parameters

    • callback: function

      The callback to run.

        • (): number[]
        • Returns number[]

    Returns this

Generated using TypeDoc