Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Entity

An entity in the world.

Hierarchy

  • Entity

Index

Constructors

constructor

Properties

alive

alive: boolean

Whether or not the entity is alive or removed.

id

id: number

A unique ID for this entity.

Methods

addComponent

  • addComponent<C>(Component: RealComponentConstructor<C>, values?: Partial<Pick<C, Exclude<keyof C, "copy" | "clone" | "reset" | "dispose">>>): Entity
  • Add a component to the entity.

    Type parameters

    Parameters

    • Component: RealComponentConstructor<C>

      Type of component to add to this entity

    • Optional values: Partial<Pick<C, Exclude<keyof C, "copy" | "clone" | "reset" | "dispose">>>

      Optional values to replace the default attributes on the component

    Returns Entity

clone

  • Returns Entity

copy

  • Parameters

    Returns Entity

getComponent

  • Get an immutable reference to a component on this entity.

    Type parameters

    Parameters

    • Component: RealComponentConstructor<C>

      Type of component to get

    • Optional includeRemoved: boolean

      Whether a component that is staled to be removed should be also considered

    Returns undefined | Readonly<C>

getComponentTypes

  • Get a list of component types that have been added to this entity.

    Returns Component<any>[]

getComponents

  • getComponents(): {}
  • Get an object containing all the components on this entity, where the object keys are the component types.

    Returns {}

getComponentsToRemove

  • getComponentsToRemove(): {}
  • Get an object containing all the components that are slated to be removed from this entity, where the object keys are the component types.

    Returns {}

getMutableComponent

  • Get a mutable reference to a component on this entity.

    Type parameters

    Parameters

    Returns undefined | C

getRemovedComponent

  • Get a component that is slated to be removed from this entity.

    Type parameters

    Parameters

    Returns undefined | Readonly<C>

hasAllComponents

  • Check if the entity has all components in a list.

    Parameters

    Returns boolean

hasAnyComponents

  • Check if the entity has any of the components in a list.

    Parameters

    Returns boolean

hasComponent

  • Check if the entity has a component.

    Type parameters

    Parameters

    • Component: RealComponentConstructor<C>

      Type of component

    • Optional includeRemoved: boolean

      Whether a component that is staled to be removed should be also considered

    Returns boolean

hasRemovedComponent

  • Check if the entity has a component that is slated to be removed.

    Type parameters

    Parameters

    Returns boolean

remove

  • remove(forceImmediate?: boolean): void
  • Remove this entity from the world.

    Parameters

    • Optional forceImmediate: boolean

      Whether this entity should be removed immediately

    Returns void

removeAllComponents

  • removeAllComponents(forceImmediate?: boolean): void
  • Remove all components on this entity.

    Parameters

    • Optional forceImmediate: boolean

      Whether all components should be removed immediately

    Returns void

removeComponent

  • Remove a component from the entity.

    Type parameters

    Parameters

    • Component: RealComponentConstructor<C>

      Type of component to remove from this entity

    • Optional forceImmediate: boolean

      Whether a component should be removed immediately

    Returns Entity

reset

  • reset(): void
  • Returns void

Generated using TypeDoc