Entities
Overseer.Entity — TypeCan be thought of as simply an index to retrieve data associated with the Entity from Components or a Ledger. In the case of a Ledger it will return an EntityState that holds references to all the Components for which the Entity has data.
An Entity should always first be created from an AbstractLedger by using Entity(ledger, comps...) before it is used.
Example
e = Entity(ledger, Comp1(), Comp2())
ledger[e] # EntityState with references to easily retrieve e's data for Comp1 and Comp2
ledger[Comp2][e] # access the Comp2 data of e
ledger[e][Comp2] # identical to aboveOverseer.EntityState — TypeCombination of an Entity and a bunch of Components for which the Entity has data. It can thus be used as an index similar to a standard Entity, but it also provides some nice ways to retrieve the data associated with it in the Components.
Example
@component struct Comp1
comp1
end
@component mutable struct Comp2
comp2
end
@component struct Comp3
comp3
end
for e in @entities_in(ledger, Comp1 && Comp2)
# e is an EntityState
# we can directly access the fields of Comp1 and Comp2 since they have unique names,
# and assign a Comp3 to the Entity that's represented by the EntityState
ledger[Comp3][e] = Comp3(e.comp1 + e.comp2)
# If there are components that have the same name in the EntityState you can access them directly
e[Comp1].comp1
e[Comp2].comp2
# If the Components are mutable we can also set their fields using
e.comp2 = 3
endOverseer.entity — Functionentity(c, i)Return the EntityState with the ith Entity and data in Component c.
Overseer.last_entity — Functionlast_entity(c::AbstractComponent)Retrieves the last Entity in c.