This signal is dispatched when a component is added to the entity.
This signal is dispatched when a component is removed from the entity.
Dispatched when the name of the entity changes. Used internally by the engine to track entities based on their names.
All entities have a name. If no name is set, a default name is used. Names are used to fetch specific entities from the engine, and can also help to identify an entity when debugging.
Add a component to the entity.
The component object to add.
The class of the component. This is only necessary if the component extends another component class and you want the framework to treat the component as of the base class type. If not set, the class type is determined directly from the component.
A reference to the entity. This enables the chaining of calls to add, to make creating and configuring entities cleaner. e.g.
const entity:Entity = new Entity()
.add(new Position(100, 200)
.add(new Display(new PlayerClip());
Get a component from the entity.
The class of the component requested.
The component, or null if none was found.
Does the entity have a component of a particular type.
The class of the component sought.
true if the entity has a component of the type, false if not.
Remove a component from the entity.
The class of the component to be removed.
the component, or null if the component doesn't exist in the entity
Generated using TypeDoc
An entity is composed from components. As such, it is essentially a collection object for components. Sometimes, the entities in a game will mirror the actual characters and objects in the game, but this is not necessary.
Components are simple value objects that contain data relevant to the entity. Entities with similar functionality will have instances of the same components. So we might have a position component
Example
All entities that have a position in the game world, will have an instance of the position component. Systems operate on entities based on the components they have.