src/necsus/runtime/spawn

Types

FullSpawn[C] = distinct RawSpawn[C]
Describes a type that is able to create new entities. Where C is a tuple with all the components to initially attach to this entity. Returns the new EntityId
RawSpawn[C] = ref object
A callback for populating a component with values
Spawn[C] = distinct RawSpawn[C]
Describes a type that is able to create new entities. Where C is a tuple with all the components to initially attach to this entity. Does not return the new EntityId

Procs

proc asFullSpawn[Comps](rawSpawn: RawSpawn[Comps]): FullSpawn[Comps]
proc asSpawn[Comps](rawSpawn: RawSpawn[Comps]): Spawn[Comps]
proc beginSpawn[Comps: tuple](world: var World; store: ptr ArchetypeStore[Comps]): NewArchSlot[
    Comps] {.inline, ...gcsafe, raises: [].}
Spawns an entity in this archetype
proc newSpawn[Comps: tuple](app: pointer; callback: proc (app: pointer;
    value: sink Comps): EntityId {.nimcall, ...raises: [], gcsafe.}): RawSpawn[
    Comps]
proc set[C: tuple](spawn: FullSpawn[C]; values: sink C): EntityId {.inline.}
Spawns an entity with the given components
proc set[C: tuple](spawn: Spawn[C]; values: sink C) {....raises: [], inline.}
Spawns an entity with the given components

Templates

template with[C: tuple](spawn: FullSpawn[C]; values: varargs[typed]): EntityId
spawns the given values
template with[C: tuple](spawn: Spawn[C]; values: varargs[typed])
spawns the given values