mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
Merge branch 'main' of https://github.com/Ukendio/jecs
Some checks failed
Some checks failed
This commit is contained in:
commit
0064f24924
5 changed files with 37 additions and 15 deletions
2
.github/workflows/analysis.yaml
vendored
2
.github/workflows/analysis.yaml
vendored
|
@ -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: |
|
||||
|
|
|
@ -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.
|
|
@ -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
29
jecs.d.ts
vendored
|
@ -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 {
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue