Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Entity

classdesc

Class representing an entity.

Hierarchy

  • Entity

Index

Constructors

constructor

  • description

    Create an entity. An object can be used when loading a previously created entity from disk, or creating an entity to be used as an assembly to clone into new entity instances.

    Parameters

    Returns Entity

Accessors

componentTypes

  • get componentTypes(): string[]
  • description

    Get all of the entity's component types.

    readonly

    Returns string[]

    • Array of component types

components

  • description

    Get all of the entity's component instances.

    readonly

    Returns Component[]

    • Array of component instances

json

  • get json(): string
  • description

    Get the entity's data as a JSON string.

    readonly

    Returns string

    • JSON string

name

  • get name(): string
  • description

    Get the entity's name.

    readonly

    Returns string

    • Name string

type

  • get type(): string
  • description

    Get the entity's type.

    readonly

    Returns string

    • Type string

uuid

  • get uuid(): string
  • description

    Get the entity's UUID.

    readonly

    Returns string

    • UUID string

Methods

Private addComponent

  • description

    Add a component instance to the entity. This method should only be called internally, and never after the entity has been registered.

    Parameters

    Returns Component[]

    • Updated array of components, or null if the component already existed

clone

copy

  • copy(source: any): void
  • description

    Copy another entity (such as an assembly) into the entity, replacing all components.

    Parameters

    • source: any

      Entity to copy

    Returns void

getComponent

  • description

    Get a component instance by type from the entity.

    readonly

    Parameters

    • type: string

      Component type

    Returns Component

    • Requested component instance

getComponentData

  • getComponentData(type: string): any
  • description

    Get data by component type from the entity. This is basically a shorthand for .getComponent.getData();

    readonly

    Parameters

    • type: string

      Component type

    Returns any

    • Requested component data

hasComponent

  • hasComponent(type: string): boolean
  • description

    Check if a component is present within the entity.

    readonly

    Parameters

    • type: string

      Component type

    Returns boolean

    • True if the component is present

isWatchableBy

  • isWatchableBy(system: System): boolean
  • description

    Check if the entity is watchable by a given system.

    readonly

    Parameters

    • system: System

      System instance

    Returns boolean

    • True if the entity is watchable

Private removeComponent

  • description

    Remove a component instance from the entity. This method should only be called internally, and never after the entity has been registered.

    Parameters

    • type: string

      Component type

    Returns Component[]

    • Array of component instances

setComponentData

  • setComponentData(type: string, data: __type): void
  • description

    Overwrite the data for a component of the given type within the entity.

    Parameters

    • type: string

      Component type

    • data: __type

      Data object

    Returns void

Generated using TypeDoc