chore: Expose world:contains and query:drain in types

This commit is contained in:
Mark Marks 2024-08-29 18:24:54 +02:00
parent e7bbf08713
commit ce70b1b2ee

View file

@ -921,9 +921,8 @@ function world_delete(world: World, entity: i53)
entityIndex.sparse[entity] = nil
end
local function world_contains(world: World, entity)
return world.entityIndex.sparse[entity]
local function world_contains(world: World, entity): boolean
return world.entityIndex.sparse[entity] ~= nil
end
type CompatibleArchetype = { archetype: Archetype, indices: { number } }
@ -1541,6 +1540,9 @@ export type World = {
parent: (self: World, entity: Entity) -> Entity,
--- Checks if the world contains the given entity
contains: (self: World, entity: Entity) -> boolean,
--- Searches the world for entities that match a given query
query: (<A>(self: World, Id<A>) -> Query<A>)
& (<A, B>(self: World, Id<A>, Id<B>) -> Query<A, B>)