Options
All
  • Public
  • Public/Protected
  • All
Menu

Class default<CT>

Type parameters

  • CT

Hierarchy

  • default

Index

Constructors

constructor

Properties

componentCollections

componentCollections: Map<string, default<CT>> = ...

dev

dev: default<CT>

entities

entities: Map<string, default<CT>> = ...

entitiesByCTypes

entitiesByCTypes: Map<string[], Set<string>> = ...

entitiesByTags

entitiesByTags: Map<Tag, Set<string>> = ...

systems

systems: default<CT>

Methods

add

  • add<T>(eid: string, component: T): this
  • Add a component on the given entity

    Type parameters

    • T

    Parameters

    • eid: string
    • component: T

    Returns this

addSystem

clearEntityComponents

  • clearEntityComponents(entityId: string): default<CT>
  • Remove all components that belong to an entity.

    Parameters

    • entityId: string

    Returns default<CT>

createEntity

  • Create an entity that is in the world. Basically just new Entity(world), but saves an import of Entity.

    Returns default<CT>

destroyEntity

  • destroyEntity(entityId: string): default<CT>
  • Destroys an entity. Same as entity.destroy().

    Parameters

    • entityId: string

    Returns default<CT>

find

  • find(predicate: (entity: default<CT>) => boolean): null | default<CT>
  • "finds" a single entity based on a predicate

    Parameters

    • predicate: (entity: default<CT>) => boolean
        • Parameters

          Returns boolean

    Returns null | default<CT>

findAll

  • "finds" all entities based on a predicate, kinda like filter.

    Parameters

    • predicate: (entity: default<CT>) => boolean
        • Parameters

          Returns boolean

    Returns default<CT>[]

get

  • Given an entity id and componentType, returns component

    Type parameters

    • T

    Parameters

    Returns T

getAllTagged

  • Gett all entities that have been tagged with the given tag.

    Parameters

    • tag: Tag

      A string or number.

    Returns default<CT>[]

getComponent

  • Find and get the first instance of a component, without any associated entities. Helpful is you know that only one instance of a component exists across all entities.

    Type parameters

    • T

    Parameters

    • cl: ClassConstructor<T>

      Component Class Contructor

    • Optional defaultValue: T

      A default component instance if no components are found.

    Returns null | T

getTagged

  • Get an entity that has been tagged with the given tag, or return null;

    Parameters

    Returns null | default<CT>

grab

  • Grabs the first entity, and its related component, that matches the component type.

    example
    const { entity, component } = world.grab(MyComponent);
    

    Type parameters

    • T

    Parameters

    Returns null | { component: T; entity: default<CT> }

grabAll

  • Grab all the components primarily, and the entities if needed

    Type parameters

    • T

    Parameters

    Returns { component: T; entity: default<CT> }[]

grabBy

  • grabBy<T>(cl: ClassConstructor<T>, predicate: (comp: T) => boolean): null | { component: T; entity: default<CT> }
  • Grab single component based on component type and predicate.

    example
    const { entity, component } = world.grabBy(FirstComponent, (comp) => comp.id == 'awesome')
    

    Type parameters

    • T

    Parameters

    • cl: ClassConstructor<T>
    • predicate: (comp: T) => boolean
        • (comp: T): boolean
        • Parameters

          • comp: T

          Returns boolean

    Returns null | { component: T; entity: default<CT> }

locate

locateAll

registerEntity

  • Setup an entity to exist in the given world. This is mostly an internal method, but exposed just in case.

    Parameters

    Returns default<CT>

remove

  • Remove a component from the given entity. NOTE: This will change what systems will be called on the entity.

    Parameters

    Returns this

Generated using TypeDoc