Skip to content

Latest commit

 

History

History
376 lines (251 loc) · 9.75 KB

API.md

File metadata and controls

376 lines (251 loc) · 9.75 KB

Constants

defineComponentobject

Defines a new component store.

registerComponent

Registers a component with a world.

registerComponents

Registers multiple components with a world.

hasComponentboolean

Checks if an entity has a component.

addComponent

Adds a component to an entity

removeComponent

Removes a component from an entity and resets component state unless otherwise specified.

setDefaultSize

Sets the default maximum number of entities for worlds and component stores.

setRemovedRecycleThreshold

Sets the number of entities that must be removed before removed entity ids begin to be recycled. This should be set to as a % (0-1) of defaultSize that you would never likely remove/add on a single frame.

addEntitynumber

Adds a new entity to the specified world.

removeEntity

Removes an existing entity from the specified world.

getEntityComponents

Returns an array of components that an entity possesses.

entityExists

Checks the existence of an entity in a world

enterQueryfunction

Given an existing query, returns a new function which returns entities who have been added to the given query since the last call of the function.

exitQueryfunction

Given an existing query, returns a new function which returns entities who have been removed from the given query since the last call of the function.

defineQueryfunction

Defines a query function which returns a matching set of entities when called on a world.

resetChangedQuery

Resets a Changed-based query, clearing the underlying list of changed entities.

removeQuery

Removes a query from a world.

defineSerializerfunction

Defines a new serializer which targets the given components to serialize the data of when called on a world or array of EIDs.

defineDeserializerfunction

Defines a new deserializer which targets the given components to deserialize onto a given world.

defineSystemfunction

Defines a new system function.

createWorldobject

Creates a new world.

resetWorldobject

Resets a world.

deleteWorld

Deletes a world.

getWorldComponents

Returns all components registered to a world

getAllEntities

Returns all existing entities in a world


defineComponent ⇒ object

Defines a new component store.

Param Type
schema object


registerComponent

Registers a component with a world.

Param Type
world World
component Component


registerComponents

Registers multiple components with a world.

Param Type
world World
components Component


hasComponent ⇒ boolean

Checks if an entity has a component.

Param Type
world World
component Component
eid number


addComponent

Adds a component to an entity

Param Type Default
world World
component Component
eid number
[reset] boolean false


removeComponent

Removes a component from an entity and resets component state unless otherwise specified.

Param Type Default
world World
component Component
eid number
[reset] boolean true


setDefaultSize

Sets the default maximum number of entities for worlds and component stores.

Param Type
newSize number


setRemovedRecycleThreshold

Sets the number of entities that must be removed before removed entity ids begin to be recycled. This should be set to as a % (0-1) of defaultSize that you would never likely remove/add on a single frame.

Param Type
newThreshold number


addEntity ⇒ number

Adds a new entity to the specified world.

Returns: number - eid

Param Type
world World


removeEntity

Removes an existing entity from the specified world.

Param Type
world World
eid number


getEntityComponents

Returns an array of components that an entity possesses.

Param Type
world *
eid *


entityExists

Checks the existence of an entity in a world

Param Type
world World
eid number


enterQuery ⇒ function

Given an existing query, returns a new function which returns entities who have been added to the given query since the last call of the function.

Returns: function - enteredQuery

Param Type
query function


exitQuery ⇒ function

Given an existing query, returns a new function which returns entities who have been removed from the given query since the last call of the function.

Returns: function - enteredQuery

Param Type
query function


defineQuery ⇒ function

Defines a query function which returns a matching set of entities when called on a world.

Returns: function - query

Param Type
components array


resetChangedQuery

Resets a Changed-based query, clearing the underlying list of changed entities.

Param Type
world World
query function


removeQuery

Removes a query from a world.

Param Type
world World
query function


defineSerializer ⇒ function

Defines a new serializer which targets the given components to serialize the data of when called on a world or array of EIDs.

Returns: function - serializer

Param Type Default
target object, array
[maxBytes] number 20000000


defineDeserializer ⇒ function

Defines a new deserializer which targets the given components to deserialize onto a given world.

Returns: function - deserializer

Param Type
target object, array


defineSystem ⇒ function

Defines a new system function.

Param Type
update function


createWorld ⇒ object

Creates a new world.


resetWorld ⇒ object

Resets a world.

Param Type
world World


deleteWorld

Deletes a world.

Param Type
world World


getWorldComponents ⇒

Returns all components registered to a world

Returns: Array

Param Type
world World


getAllEntities ⇒

Returns all existing entities in a world

Returns: Array

Param Type
world World