Types
ArchetypeStore[Comps] = object
- Stores a specific archetype shape
ArchRow[Comps] = object entityId*: EntityId components*: Comps
- A row of data stored about an entity that matches a specific archetype
NewArchSlot[Comps] = distinct Entry[ArchRow[Comps]]
Procs
proc `=copy`[Comps: tuple](target: var ArchetypeStore[Comps]; source: ArchetypeStore[Comps]) {.error.}
func addLen[Comps: tuple](store: var ArchetypeStore[Comps]; len: var uint)
- Accessor for the archetype of a store
proc addLen[Comps: tuple](store: var ArchetypeStore[Comps]; len: var uint; predicate: proc (row: var Comps): bool {.nimcall, ...gcsafe, raises: [].})
- Reads the length of an archetype store, using a predicate to determine whether to count a row
proc del(store: var ArchetypeStore; index: uint)
- Return the components for an archetype
proc ensureAlloced[Comps: tuple](store: var ArchetypeStore[Comps])
- Allocs the memory for this archetype if it hasn't been alloced already
proc entityId[Comps: tuple](entry: NewArchSlot[Comps]): EntityId
proc getComps[Comps: tuple](store: var ArchetypeStore[Comps]; index: uint): ptr Comps
- Return the components for an archetype
proc index[Comps: tuple](entry: NewArchSlot[Comps]): uint
proc moveEntity[FromArch: tuple; NewComps: tuple; ToArch: tuple]( world: var World; entityIndex: ptr EntityIndex; fromArch: var ArchetypeStore[FromArch]; toArch: var ArchetypeStore[ToArch]; newValues: sink NewComps; combine: proc (existing: sink FromArch; newValues: sink NewComps; output: var ToArch): bool {....gcsafe, raises: [], nimcall.}) {....gcsafe, raises: [ValueError].}
- Moves the components for an entity from one archetype to another
proc newArchetypeStore[Comps: tuple](archetype: ArchetypeId; initialSize: SomeInteger): ArchetypeStore[ Comps]
- Creates a new storage block for an archetype
proc newSlot[Comps: tuple](store: var ArchetypeStore[Comps]; entityId: EntityId): NewArchSlot[ Comps]
- Reserves a slot for storing a new component
proc next[Comps: tuple](store: var ArchetypeStore[Comps]; iter: var BlockIter; eid: var EntityId): ptr Comps
- Returns the next row of components in this archetype store
proc readArchetype(store: ArchetypeStore): ArchetypeId {.inline.}
- Accessor for the archetype of a store
proc setComp[Comps: tuple](slot: NewArchSlot[Comps]; comps: sink Comps): EntityId
- Stores an entity and its components into this slot
Iterators
iterator entityIds[Comps](store: var ArchetypeStore[Comps]): EntityId