Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Entity

Bundles together one or more components to create a game entity Usage:

const entity = new Entity();
entity.add(new Health(20));

Hierarchy

Index

Constructors

Methods

Constructors

constructor

Methods

add

get

  • get<C>(component: {}): C
  • Returns the component instance for the specified component. Useful if you need to modify values on the component

    Type parameters

    Parameters

    • component: {}

      The constructor of a component

    Returns C

    Returns the component instance

has

  • has(component: {}): boolean
  • Parameters

    • component: {}

      The constructor of a component

    Returns boolean

    true | false depending on if this entity has the specified component

ifHas

  • ifHas<C>(component: {}, fn: (c: C) => void): void
  • Executes the provided function if this entity has the specified component

    Type parameters

    Parameters

    • component: {}

      The constructor of a component

    • fn: (c: C) => void

      A function to be executed if the entity has the component

        • (c: C): void
        • Parameters

          • c: C

          Returns void

    Returns void

remove

  • remove(component: {}): void
  • Remove a component from this entity.

    Parameters

    • component: {}

    Returns void

Generated using TypeDoc