An array of all entities within the bucket. Please note that for iterating
over the entities in this bucket, it is recommended that you use the
for (const entity of bucket) iterator form.
Returns the first entity in the bucket, or undefined if the bucket is empty.
Returns the total size of the bucket, i.e. the number of entities it contains.
The current version of the bucket. Increases every time an entity is added or removed.
Adds a component to an entity. If the entity already has the component, the existing component will not be overwritten.
After the component was added, the entity will be reindexed, causing it to be added to or removed from any queries depending on their criteria.
Removes all entities from the bucket. Will cause the onEntityRemoved event to be
fired for each entity.
Given an entity ID that was previously generated through the id(entity) function,
returns the entity matching that ID, or undefined if no such entity exists.
The ID of the entity to retrieve.
The entity with the given ID, or undefined if no such entity exists.
Returns true if the bucket contains the given entity.
The entity to check for.
true if the specificed entity is in this bucket, false otherwise.
Generate and return a numerical identifier for the given entity. The ID can later
be used to retrieve the entity again through the entity(id) method.
The entity to get the ID for.
An ID for the entity, or undefined if the entity is not in the world.
Creates (or reuses) a query that matches the given configuration.
The query configuration.
A query that matches the given configuration.
Reindexes the specified entity. This will iteratere over all registered queries and ask them to reevaluate the entity.
If the future parameter is specified,
it will be used in the evaluation instead of the entity itself. This is useful
if you are about to perform a destructive change on the entity (like removing
a component), but want emitted events to still have access to the unmodified entity
before the change.
Removes a component from an entity. If the entity does not have the component, this function does nothing.
After the component was removed, the entity will be reindexed, causing it to be added to or removed from any queries depending on their criteria.
Creates (or reuses) a query that holds entities that match the given predicate. Please note that as soon as you are building queries that use predicates, you will need to explicitly reindex entities when their properties change.
A query that holds entities that match the given predicate.
Creates (or reuses) a query that holds entities that have all of the specified components.
One or more component names to query for.
A query that holds entities that have all of the given components.
Creates (or reuses) a query that holds entities that do not have any of the specified components.
One or more component names to query for.
A query that holds entities that do not have any of the given components.
Fired when an entity has been added to the bucket.