# Class: EntityFactory<TEntityConfig, TContext>

A factory to assemble entities from blueprints.

# Type parameters

Name Description
TEntityConfig The entity configuration type.
TContext The context type.

# Table of contents

# Constructors

# Methods

# Constructors

# constructor

new EntityFactory<TEntityConfig, TContext>(componentFactories, context, allocator)

Creates a new EntityFactory.

# Type parameters

Name
TEntityConfig
TContext

# Parameters

Name Type Description
componentFactories ComponentFactoryRegistry<any, any> The component factory registry to use.
context TContext The context to pass to component factories.
allocator Allocator The entity/component allocator to use.

# Defined in

src/factory/EntityFactory.ts:39 (opens new window)

# Methods

# addEntityBlueprint

addEntityBlueprint(name, blueprint): void

# Parameters

Name Type Description
name string The name used to identify the entity blueprint.
blueprint ComponentBlueprint<any>[] The list of component blueprints for this entity.

# Returns

void

# Defined in

src/factory/EntityFactory.ts:54 (opens new window)


# assemble

assemble(blueprintName, overrides?): Entity

Creates and assembles an Entity.

throws An exception if the entity could not be assembled.

# Parameters

Name Type Description
blueprintName string The name of the entity blueprint.
overrides? EntityConfigOverrides<TEntityConfig> A map of overrides.

# Returns

Entity

A fully assembled Entity or null if the assembly failed.

# Defined in

src/factory/EntityFactory.ts:66 (opens new window)