Group
Description:
A record representing a group of entities in the ECS game systems.
Class Object: Group Class.
Inherits from: Object.
count
Type: Readonly Field.
Description:
The number of entities in the group.
Signature:
const count: integer
first
Type: Readonly Field.
Description:
The first entity in the group, or nil if the group is empty.
Signature:
const first: Entity
each
Type: Function.
Description:
Calls a function for each entity in the group.
Signature:
each: function(self: Group, func: function(Entity): boolean): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
func | function | The function to call for each entity. Returning true inside the function to stop iteration. |
Returns:
Return Type | Description |
---|---|
boolean | False if all entities were processed, True if the iteration was interrupted. |
find
Type: Function.
Description:
Finds the first entity in the group that satisfies a predicate function.
Signature:
find: function(self: Group, func: function(Entity): boolean): Entity
Parameters:
Parameter | Type | Description |
---|---|---|
func | function | The predicate function to test each entity with. |
Returns:
Return Type | Description |
---|---|
Entity | The first entity that satisfies the predicate, or nil if no entity does. |
watch
Type: Function.
Description:
Watches the group for changes to its entities, calling a function whenever an entity is added or changed.
Signature:
watch: function(self: Group, func: function(Entity): boolean): Group
Parameters:
Parameter | Type | Description |
---|---|---|
func | function | The function to call when an entity is added or changed. Returns true to stop watching. |
Returns:
Return Type | Description |
---|---|
Group | The same group, for method chaining. |