Skip to content

Class: SystemEntity

SystemEntity is a wrapper around an entity and its components, used in systems to provide an easier way to group an entity and its components. Includes a number of helper functions for retrieving/adding/removing components, and destroying the entity.

Table of contents

Constructors

Properties

Methods

Constructors

constructor

+ new SystemEntity(entity: IEntity, components: Component[]): SystemEntity

Parameters:

Name Type
entity IEntity
components Component[]

Returns: SystemEntity

Properties

entity

entity: IEntity

Methods

Add

Add(component: Component): void

Add adds a component to an entity.

Parameters:

Name Type Description
component Component The component to add

Returns: void


Destroy

Destroy(): void

Destroy destroys the entity and all of its components.

Returns: void


Get

Get(key: string): undefined | Component

Get returns any Component with the key provided if it exists; otherwise it returns undefined.

Parameters:

Name Type Description
key string The key identifier of the component

Returns: undefined | Component

The component if it exists, otherwise undefined


Remove

Remove(key: string): void

Remove removes a component from an entity.

Parameters:

Name Type Description
key string The key of the component to remove

Returns: void