API Docs for:
Show:

Entity Class

Defined in: ../src/Entity.js:4
Module: ArtemiJS

The entity class. Cannot be instantiated outside the framework, you must create new entities using World.

Methods

addComponent

(
  • component
  • [type]
)
chainable

Add a component to this entity.

Parameters:

addToWorld

()

Refresh all changes to components for this entity. After adding or removing components, you must call this method. It will update all relevant systems. It is typical to call this after adding components to a newly created entity.

changedInWorld

()

This entity has changed, a component added or deleted.

deleteFromWorl

()

Delete this entity from the world.

disable

()

Disable the entity from being processed. Won't delete it, it will continue to exist but won't get processed.

enable

()

(Re)enable the entity in the world, after it having being disabled. Won't do anything unless it was already disabled.

getComponent

(
  • [type]
)
ArtemiJS.Component

This is the preferred method to use when retrieving a component from a entity. It will provide good performance. But the recommended way to retrieve components from an entity is using the ComponentMapper.

Parameters:

  • [type] ComponentType optional

    in order to retrieve the component fast you must provide a ComponentType instance for the expected component.

Returns:

ArtemiJS.Component:

getComponentBits

() Utils.BitSet

Defined in ../src/Entity.js:79

Returns a BitSet instance containing bits of the components the entity possesses.

Returns:

Utils.BitSet:

getComponents

(
  • fillBag
)
Utils.Bag

Returns a bag of all components this entity has. You need to reset the bag yourself if you intend to fill it more than once.

Parameters:

  • fillBag Utils.Bag

    the bag to put the components into.

Returns:

Utils.Bag: the fillBag with the components in.

getId

() Number

Defined in ../src/Entity.js:67

The internal id for this entity within the framework. No other entity will have the same ID, but ID's are however reused so another entity may acquire this ID if the previous entity was deleted.

Returns:

Number:

getSystemBits

() Utils.BitSet

Defined in ../src/Entity.js:89

Returns a BitSet instance containing bits of the components the entity possesses.

Returns:

Utils.BitSet:

getUuid

() String

Get the UUID for this entity. This UUID is unique per entity (re-used entities get a new UUID).

Returns:

String: uuid instance for this entity.

getWorld

() ArtemiJS.World

Returns the world this entity belongs to.

Returns:

ArtemiJS.World: world of entity.

isActive

() Boolean

Checks if the entity has been added to the world and has not been deleted from it. If the entity has been disabled this will still return true.

Returns:

Boolean:

isEnabled

() Boolean

Returns:

Boolean:

removeComponent

(
  • [component]
)

Remove component by its type.

Parameters:

reset

() private

Defined in ../src/Entity.js:99

Get systems BitSet

toString

() String

Make entity ready for re-use. Will generate a new uuid for the entity.

Returns:

String:

Properties

componentBits

Utils.BitSet private

Defined in ../src/Entity.js:23

componentManager

ComponentManager private

Defined in ../src/Entity.js:58

entityManager

EntityManager private

Defined in ../src/Entity.js:51

id

Number private

Defined in ../src/Entity.js:44

systemBits

Utils.BitSet private

Defined in ../src/Entity.js:30

uuid

String private

Defined in ../src/Entity.js:16

world

World private

Defined in ../src/Entity.js:37