# Class: Allocator

An allocator can be used for obtaining new or reused entities/components. This allocator just creates new instances every time and does not support pooling.

see PoolAllocator

# Table of contents

# Constructors

# Methods

# Constructors

# constructor

new Allocator()

# Methods

# freeComponent

freeComponent(_component): void

Free a component (possibly marking it for reuse).

# Parameters

Name Type Description
_component Component The component to free.

# Returns

void

# Defined in

src/core/Allocator.ts:39 (opens new window)


# freeEntity

freeEntity(_entity): void

Free an entity (possibly marking it for reuse).

# Parameters

Name Type Description
_entity Entity The entity to free.

# Returns

void

# Defined in

src/core/Allocator.ts:21 (opens new window)


# obtainComponent

obtainComponent<T>(Class): T

# Type parameters

Name Type Description
T extends Component<T> The component class to obtain, do not specify manually!

# Parameters

Name Type Description
Class NoArgsComponentConstructor<T> The component constructor to use.

# Returns

T

A new or reused component of the specified class.

# Defined in

src/core/Allocator.ts:30 (opens new window)


# obtainEntity

obtainEntity(): Entity

# Returns

Entity

A new or reused entity.

# Defined in

src/core/Allocator.ts:12 (opens new window)