Merge branch 'main' of https://github.com/Ukendio/jecs
Some checks failed
analysis / Run Luau Analyze (push) Has been cancelled
deploy-docs / build (push) Has been cancelled
publish-npm / publish (push) Has been cancelled
unit-testing / Run Luau Tests (push) Has been cancelled
deploy-docs / Deploy (push) Has been cancelled

This commit is contained in:
Ukendio 2025-02-09 20:38:08 +01:00
commit 0064f24924
5 changed files with 37 additions and 15 deletions

View file

@ -12,7 +12,7 @@ jobs:
uses: actions/checkout@v4
- name: Install Luau
uses: encodedvenom/install-luau@v2.1
uses: encodedvenom/install-luau@v4.3
- name: Analyze
run: |

View file

@ -21,3 +21,8 @@ An ergonomic, runtime agnostic scheduler for Jecs
## [jam](https://github.com/revvy02/Jam)
Provides hooks and a scheduler that implements jabby and a topographical runtime
## [planck](https://github.com/YetAnotherClown/planck)
An agnostic scheduler inspired by Bevy and Flecs, with core features including phases, pipelines, run conditions, and startup systems.
Planck also provides plugins for Jabby, Matter Hooks, and more.

View file

@ -47,22 +47,10 @@ Get parent for entity
world:parent(bob)
```
```typescript [typescript]
world.parent(bob, pair(Eats, jecs.Wildcard)
world.parent(bob)
```
:::
Find first target of a relationship for entity
:::code-group
```luau [luau]
world:target(bob, Eats)
```
```typescript [typescript]
world.target(bob, Eats)
```
:::
Find first target of a relationship for entity
:::code-group

29
jecs.d.ts vendored
View file

@ -40,6 +40,23 @@ type FlattenTuple<T extends unknown[]> = T extends [infer U] ? U : LuaTuple<T>;
type Nullable<T extends unknown[]> = { [K in keyof T]: T[K] | undefined };
type InferComponents<A extends Id[]> = { [K in keyof A]: InferComponent<A[K]> };
type ArchetypeId = number
type Column = unknown[];
type ArchetypeRecord = {
count: number;
column: number;
}
export type Archetype = {
id: number;
types: number[];
type: string;
entities: number[];
columns: Column[];
records: ArchetypeRecord[];
}
type Iter<T extends unknown[]> = IterableFunction<LuaTuple<[Entity, ...T]>>;
export type CachedQuery<T extends unknown[]> = {
@ -47,6 +64,12 @@ export type CachedQuery<T extends unknown[]> = {
* Returns an iterator that produces a tuple of [Entity, ...queriedComponents].
*/
iter(): Iter<T>;
/**
* Returns the matched archetypes of the query
* @returns An array of archetypes of the query
*/
archetypes(): Archetype[];
} & Iter<T>;
export type Query<T extends unknown[]> = {
@ -75,6 +98,12 @@ export type Query<T extends unknown[]> = {
* @returns A new Query with the exclusion applied.
*/
without(...components: Id[]): Query<T>;
/**
* Returns the matched archetypes of the query
* @returns An array of archetypes of the query
*/
archetypes(): Archetype[];
} & Iter<T>;
export class World {

View file

@ -2188,7 +2188,7 @@ function World.new()
return self
end
export type Entity<T = nil> = number & { __T: T }
export type Entity<T = unknown> = {__T: T}
export type Id<T = nil> =
| Entity<T>