Members
Methods
addComponents(…components) → {Entity}
Adds all the specified components to the entity.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
components |
Component |
<repeatable> |
the components to add |
Fires:
- Entity#entity:add
- Entity#entity:add:{type}
- module:transvolve#event:error
Throws
- TypeError
- Will throw this error when an argument other than a Component is passed.
- ReferenceError
- Will throw this error When invoked after the entity has been disposed.
getComponents(…types) → {Component|Map.<string, Component>}
Gets all components contained in the entity for specified component types. Returns only a single component if
only one type is specified, but returns a map of all components is returned if no types are specified.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
types |
string |
<repeatable> |
the desired types of components |
Fires:
- module:transvolve#event:error
Throws
- TypeError
- when an argument other than a string is passed.
- ReferenceError
- when invoked after the entity has been disposed.
getId() → {integer}
Get the id.
Throws
- ReferenceError
- Will throw this error if invoked after being disposed.
Returns
The entity id.
- Type
- integer
hasComponents(…types) → {boolean}
Determines if the entity has components of all the specified types.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
types |
string |
<repeatable> |
The component types |
Throws
- TypeError
- Will throw this error when an argument other than a string is passed.
- ReferenceError
- Will throw this error when invoked after the entity has been disposed.
Returns
The result
- Type
- boolean
removeComponents(…componentsOrTypes) → {Entity}
Removes all the specified components or types of components from the entity.
Each component that is removed is disposed.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
componentsOrTypes |
Component | string |
<repeatable> |
the components and/or component types to remove |
Fires:
- Entity#entity:remove
- Entity#entity:remove:{type}
- module:transvolve#event:error
Throws
- TypeError
- Will throw this error when an argument other than a Component is passed.
- ReferenceError
- Will throw this error when invoked after the entity has been disposed.
Events
entity:add
An entity:add event occurs when an entity adds a component.
entity:add:{type}
An entity:add:{type} event occurs when an entity adds a component.
entity:change
An entity:change event occurs when a component, that an entity owns, changes.
entity:change:{type}
A entity:change:{type} event occurs when a component, that an entity owns, changes.
entity:dispose
An entity:dispose event occurs when an entity is being disposed.
entity:remove
An entity:remove event occurs when an entity disposes a component.