classdesc

  Class representing an entity.

### Hierarchy

- Entity

## Index

### Constructors

- constructor

### Accessors

- componentTypes
- components
- json
- name
- type
- uuid

### Methods

- addComponent
- clone
- copy
- getComponent
- getComponentData
- hasComponent
- isWatchableBy
- removeComponent
- setComponentData

## Constructors

### constructor

- new Entity(config?: EntityConfig): Entity

- - Defined in core/Entity.ts:19
  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

  - ##### Optional config: EntityConfig

  #### Returns Entity

## Accessors

### componentTypes

- get componentTypes(): string[]

- - Defined in core/Entity.ts:68
  description

    Get all of the entity's component types.

  readonly

  #### Returns string[]

  - Array of component types

### components

- get components(): Component[]

- - Defined in core/Entity.ts:59
  description

    Get all of the entity's component instances.

  readonly

  #### Returns Component[]

  - Array of component instances

### json

- get json(): string

- - Defined in core/Entity.ts:81
  description

    Get the entity's data as a JSON string.

  readonly

  #### Returns string

  - JSON string

### name

- get name(): string

- - Defined in core/Entity.ts:103
  description

    Get the entity's name.

  readonly

  #### Returns string

  - Name string

### type

- get type(): string

- - Defined in core/Entity.ts:112
  description

    Get the entity's type.

  readonly

  #### Returns string

  - Type string

### uuid

- get uuid(): string

- - Defined in core/Entity.ts:121
  description

    Get the entity's UUID.

  readonly

  #### Returns string

  - UUID string

## Methods

### Private addComponent

- addComponent(component: Component): Component[]

- - Defined in core/Entity.ts:132
  description

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

  #### Parameters

  - ##### component: Component

    The component to add

  #### Returns Component[]

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

### clone

- clone(): Entity

- - Defined in core/Entity.ts:144
  description

    Clone the entity.

  #### Returns Entity

  - New Entity instance

### copy

- copy(source: any): void

- - Defined in core/Entity.ts:154
  description

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

  #### Parameters

  - ##### source: any

    Entity to copy

  #### Returns void

### getComponent

- getComponent(type: string): Component

- - Defined in core/Entity.ts:169
  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

- - Defined in core/Entity.ts:179
  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

- - Defined in core/Entity.ts:193
  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

- - Defined in core/Entity.ts:203
  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

- removeComponent(type: string): Component[]

- - Defined in core/Entity.ts:223
  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

- - Defined in core/Entity.ts:237
  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