# Class: EntityManager

A manager for all entities in an engine. It is responsible for keeping track of Entities.

# Table of contents

# Constructors

# Properties

# Accessors

# Methods

# Constructors

# constructor

new EntityManager(engine, allocator)

Creates a new EntityManager.

# Parameters

Name Type Description
engine Engine The engine of this manager.
allocator Allocator The allocator to use for freeing entities.

# Defined in

src/core/EntityManager.ts:71 (opens new window)

# Properties

# onAdd

Readonly onAdd: EntitySignal

Will dispatch an event after an entity has been added.

# Defined in

src/core/EntityManager.ts:60 (opens new window)


# onRemove

Readonly onRemove: EntitySignal

Will dispatch an event after an entity has been removed.

# Defined in

src/core/EntityManager.ts:63 (opens new window)

# Accessors

# delayOperations

Protected set delayOperations(shouldDelay): void

# Parameters

Name Type
shouldDelay boolean

# Returns

void

# Defined in

src/core/EntityManager.ts:77 (opens new window)


# notifying

Protected set notifying(notifying): void

# Parameters

Name Type
notifying boolean

# Returns

void

# Defined in

src/core/EntityManager.ts:83 (opens new window)

# Methods

# add

add(entity): void

Adds an entity to this manager.

throws If the entity has already been added to an entity manager.

# Parameters

Name Type Description
entity Entity The entity to add.

# Returns

void

# Defined in

src/core/EntityManager.ts:94 (opens new window)


# forFamily

forFamily(family): Entity[]

# Parameters

Name Type Description
family Family A Family instance.

# Returns

Entity[]

A list of entities for the specified Family. Will return the same instance every time.

# Defined in

src/core/EntityManager.ts:138 (opens new window)


# get

get(id): undefined | Entity

# Parameters

Name Type Description
id number The id of an Entity.

# Returns

undefined | Entity

The entity associated with the specified id or undefined if no such entity exists.

# Defined in

src/core/EntityManager.ts:125 (opens new window)


# getAll

getAll(): Entity[]

# Returns

Entity[]

A list of all entities.

# Defined in

src/core/EntityManager.ts:130 (opens new window)


# onAddForFamily

onAddForFamily(family): EntitySignal

# Parameters

Name Type Description
family Family A Family instance.

# Returns

EntitySignal

The EntitySignal which emits when an entity is added to the specified Family.

# Defined in

src/core/EntityManager.ts:146 (opens new window)


# onRemoveForFamily

onRemoveForFamily(family): EntitySignal

# Parameters

Name Type Description
family Family A Family instance.

# Returns

EntitySignal

The EntitySignal which emits when an entity is removed from the specified Family.

# Defined in

src/core/EntityManager.ts:156 (opens new window)


# remove

remove(entity): void

Removes an entity.

# Parameters

Name Type Description
entity Entity The entity to remove.

# Returns

void

# Defined in

src/core/EntityManager.ts:106 (opens new window)


# removeAll

removeAll(): void

Removes all entities.

# Returns

void

# Defined in

src/core/EntityManager.ts:116 (opens new window)


# removeInternal

Protected removeInternal(entity): void

# Parameters

Name Type
entity Entity

# Returns

void

# Defined in

src/core/EntityManager.ts:200 (opens new window)