Components
Overseer.AbstractComponent — TypeAbstract type for all Components. For now the only two AbstractComponents are Component and PooledComponent. Most functionality that is defined for the AbstractComponent type assumes that there is a .indices member field that is of type Indices.
If this is not the case look at those functions in the src/component.jl file.
Overseer.test_abstractcomponent_interface is an interface test function that you can call to test a new AbstractComponent implementation. See that function for more details.
Overseer.Component — TypeThe most basic Component type.
Indexing into a component with an Entity will return the data linked to that entity, indexing with a regular Int will return directly the data that is stored in the data vector at that index, i.e. generally not the storage linked to the Entity with that Int as id.
To register a struct to be stored in a Component see @component.
Overseer.@component — MacroThis takes a struct definition and register it so that it will be stored inside a Component when attached to Entities.
Example
```julia @component struct MyComp v::Float64 end
Overseer.PooledComponent — TypeA PooledComponent allows for sharing data between many Entities. Essentially, the indices into the data pool are stored for each Entity, rather than the data itself.
To make a struct to be stored inside PooledComponent see @pooled_component.
make_unique! can be used to check whether duplicate data exists and if so point all Entities to only a single copy and remove the duplicates.
To interact with the data pools see pool, pools and entity_pool.
Example
@pooled_component struct Comp1
comp1
end
e1 = Entity(ledger, Comp1(1))
e2 = Entity(ledger)
ledger[Comp1][e2] = e1 # The Comp1 data for e2 is set to point to the same as e1 Overseer.@pooled_component — MacroThis takes a struct definition and register it so that it will be stored inside a PooledComponent when attached to Entities.
Overseer.test_abstractcomponent_interface — FunctionTests whether an AbstractComponent satisfies the interface.
Base.in — Methodin(entity, component)Checks whether entity has a data entry in component.
Base.pop! — Methodpop!(component, entity)pops the data for entity out of component.
Overseer.make_unique! — FunctionChecks whether duplicate data exists in a PooledComponent and if so points all Entities to only a single copy while removing the duplicates.
Overseer.pool — Functionpool(pooled_compnent, entity)
pool(pooled_compnent, i)Returns which pool entity or the ith entity belongs to.
Overseer.Indices — TypeA variation on the SparseIntSet from DataStructures.jl which forms the backbone of keeping track of which Entities are part of an AbstractComponent and how to access their data.
Complexities:
in: O(1)pop!: O(1)push!: O(1)getindex: O(1)iterate: O(N)