EcsSystemIterator
What a system’s function receives: how many entities, the frame’s delta and their components.
Description
Section titled “Description”A system registered with World.system() is called with one EcsSystemIterator for a batch of matching entities. field() gives, per component, an array with one element per entity, in the same order for every component: element i of each array belongs to the same entity. See the example in World.
A system may be called several times in one phase, once per group of entities with the same set of components; count() is the size of the current batch.
Note: The iterator and its elements are reused from call to call: don’t keep them once the function returns.
Methods
Section titled “Methods”| Returns | Method |
|---|---|
| int | count() |
| float | delta() |
| void | draw_rect(rect, color, antialiased) |
| Array | field(name) |
Method descriptions
Section titled “Method descriptions”int count() const
Returns how many entities this call covers: the size of every array returned by field().
float delta() const
Returns the seconds since the previous frame (the previous physics frame for a "physics_process" system), like the delta of _process.
draw_rect
Section titled “draw_rect”void draw_rect(rect: Rect2, color: Color, antialiased: bool = false)
Draws a rectangle filled with color at rect, in the coordinates of the root viewport’s 2D world, on a canvas item the world owns. With antialiased, its edges are smoothed.
What a phase’s systems draw stays until that phase runs again: a "process" system redraws every frame, a "physics_process" one every physics tick, and each phase only clears its own drawings.
Array field(name: StringName) const
Returns the component name of every entity of this call, as an Array of EcsSystemFieldElement (count() elements). Reading an element’s field reads the entity’s component, and writing it changes the component in place.
With the struct declared in the same script, the elements’ fields are typed and checked by the compiler; otherwise they have no known type in Grost and are taken with as. Returns an empty array if name isn’t one of the system’s components.