Iteration
Overseer.@entities_in — Macro@entities_in(comp_expr)
@entities_in(l, comp_expr)This macro creates an iterator that iterates over all entities that are present in the components according to the expression passed to it. Each iteration an EntityState is returned that refers to the entity and the associated data inside the Components.
comp_expr is a boolean expression that is used to decide which entities to return.
Examples
for e in @entities_in(comp1 && (comp2 || comp3) && !comp4)
# do something with e
end
for e in @entities_in(ledger, CompType1 && (CompType2 || CompType3) && !CompType4)
# do something with e
endAssuming that comp1 = ledger[CompType1] and similar for the others, these expressions will loop over the Entities that are in comp1, in comp2 or comp3, and not in comp4.
Overseer.@safe_entities_in — Macro@safe_entities_in(comp_expr)
@safe_entities_in(ledger, comp_expr)Similar to @entities_in but safe to pop! entities during iteration.
Overseer.pools — Functionpools(c::PooledComponent)Returns an iterator that loops over the pools in c, returning a Tuple with the data and an iterator like the one gotten from entity_pool.
Example
for (data, entities) in pools(c)
for e in entities
# do something with e
end
endOverseer.entity_pool — Functionentity_pool(c::PooledComponent, pool_id::Int)
entity_pool(c::PooledComponent, e::AbstractEntity)Returns an iterator that iterates over all the Entities in the pool with id == pool_id or the pool to which e belongs.
Example
for e in entity_pool(c, 1)
# do something with e belonging to the first pool of c
end