Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Ukendio/jecs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ukendio committed Feb 9, 2025
2 parents 1937529 + 6ec0b0b commit 0064f24
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
5 changes: 5 additions & 0 deletions docs/learn/concepts/addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
14 changes: 1 addition & 13 deletions docs/learn/concepts/relationships.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions jecs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,36 @@ 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[]> = {
/**
* 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[]> = {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion jecs.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 0064f24

Please sign in to comment.