fix: Type functions that accepted entities and pairs to actually accept pairs

This commit is contained in:
Mark Marks 2024-08-28 19:18:32 +02:00
parent ff98e8b5fb
commit 5225b2250b

View file

@ -1440,6 +1440,8 @@ function World.new()
return self return self
end end
export type Id<T = nil> = Entity<T> | Pair
export type Pair = number export type Pair = number
type Item<T...> = (self: Query<T...>) -> (Entity, T...) type Item<T...> = (self: Query<T...>) -> (Entity, T...)
@ -1482,67 +1484,67 @@ export type World = {
delete: (self: World, id: Entity) -> (), delete: (self: World, id: Entity) -> (),
--- Adds a component to the entity with no value --- Adds a component to the entity with no value
add: <T>(self: World, id: Entity, component: Entity<T>) -> (), add: <T>(self: World, id: Entity, component: Id<T>) -> (),
--- Assigns a value to a component on the given entity --- Assigns a value to a component on the given entity
set: <T>(self: World, id: Entity, component: Entity<T>, data: T) -> (), set: <T>(self: World, id: Entity, component: Id<T>, data: T) -> (),
-- Clears an entity from the world -- Clears an entity from the world
clear: (self: World, id: Entity) -> (), clear: (self: World, id: Entity) -> (),
--- Removes a component from the given entity --- Removes a component from the given entity
remove: (self: World, id: Entity, component: Entity) -> (), remove: (self: World, id: Entity, component: Id) -> (),
--- Retrieves the value of up to 4 components. These values may be nil. --- Retrieves the value of up to 4 components. These values may be nil.
get: (<A>(self: World, id: any, Entity<A>) -> A) get: (<A>(self: World, id: any, Id<A>) -> A?)
& (<A, B>(self: World, id: Entity, Entity<A>, Entity<B>) -> (A, B)) & (<A, B>(self: World, id: Entity, Id<A>, Id<B>) -> (A?, B?))
& (<A, B, C>(self: World, id: Entity, Entity<A>, Entity<B>, Entity<C>) -> (A, B, C)) & (<A, B, C>(self: World, id: Entity, Id<A>, Id<B>, Id<C>) -> (A?, B?, C?))
& <A, B, C, D>(self: World, id: Entity, Entity<A>, Entity<B>, Entity<C>, Entity<D>) -> (A, B, C, D), & <A, B, C, D>(self: World, id: Entity, Id<A>, Id<B>, Id<C>, Id<D>) -> (A?, B?, C?, D?),
has: (self: World, ...Entity) -> boolean, has: (self: World, ...Id) -> boolean,
parent: (self: World, entity: Entity) -> Entity, parent: (self: World, entity: Entity) -> Entity,
--- Searches the world for entities that match a given query --- Searches the world for entities that match a given query
query: (<A>(self: World, Entity<A>) -> Query<A>) query: (<A>(self: World, Id<A>) -> Query<A>)
& (<A, B>(self: World, Entity<A>, Entity<B>) -> Query<A, B>) & (<A, B>(self: World, Id<A>, Id<B>) -> Query<A, B>)
& (<A, B, C>(self: World, Entity<A>, Entity<B>, Entity<C>) -> Query<A, B, C>) & (<A, B, C>(self: World, Id<A>, Id<B>, Id<C>) -> Query<A, B, C>)
& (<A, B, C, D>(self: World, Entity<A>, Entity<B>, Entity<C>, Entity<D>) -> Query<A, B, C, D>) & (<A, B, C, D>(self: World, Id<A>, Id<B>, Id<C>, Id<D>) -> Query<A, B, C, D>)
& (<A, B, C, D, E>( & (<A, B, C, D, E>(
self: World, self: World,
Entity<A>, Id<A>,
Entity<B>, Id<B>,
Entity<C>, Id<C>,
Entity<D>, Id<D>,
Entity<E> Id<E>
) -> Query<A, B, C, D, E>) ) -> Query<A, B, C, D, E>)
& (<A, B, C, D, E, F>( & (<A, B, C, D, E, F>(
self: World, self: World,
Entity<A>, Id<A>,
Entity<B>, Id<B>,
Entity<C>, Id<C>,
Entity<D>, Id<D>,
Entity<E>, Id<E>,
Entity<F> Id<F>
) -> Query<A, B, C, D, E, F>) ) -> Query<A, B, C, D, E, F>)
& (<A, B, C, D, E, F, G>( & (<A, B, C, D, E, F, G>(
self: World, self: World,
Entity<A>, Id<A>,
Entity<B>, Id<B>,
Entity<C>, Id<C>,
Entity<D>, Id<D>,
Entity<E>, Id<E>,
Entity<F>, Id<F>,
Entity<G> Id<G>
) -> Query<A, B, C, D, E, F, G>) ) -> Query<A, B, C, D, E, F, G>)
& (<A, B, C, D, E, F, G, H>( & (<A, B, C, D, E, F, G, H>(
self: World, self: World,
Entity<A>, Id<A>,
Entity<B>, Id<B>,
Entity<C>, Id<C>,
Entity<D>, Id<D>,
Entity<E>, Id<E>,
Entity<F>, Id<F>,
Entity<G>, Id<G>,
Entity<H>, Id<H>,
...Entity<any> ...Id<any>
) -> Query<A, B, C, D, E, F, G, H>), ) -> Query<A, B, C, D, E, F, G, H>),
} }