mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
Close code groups
This commit is contained in:
parent
8e27a46043
commit
77be39a2b6
1 changed files with 3 additions and 0 deletions
|
@ -24,6 +24,7 @@ for _ in world:query(Position, Velocity) do end
|
||||||
```typescript [typescript]
|
```typescript [typescript]
|
||||||
for (const [_] of world.query(Position, Velocity)) {}
|
for (const [_] of world.query(Position, Velocity)) {}
|
||||||
```
|
```
|
||||||
|
:::
|
||||||
|
|
||||||
### Components
|
### Components
|
||||||
A component is any single ID that can be added to an entity. This includes tags and regular entities, which are IDs that do not have the builtin `Component` component. To match a query, an entity must have all the requested components. An example:
|
A component is any single ID that can be added to an entity. This includes tags and regular entities, which are IDs that do not have the builtin `Component` component. To match a query, an entity must have all the requested components. An example:
|
||||||
|
@ -71,6 +72,7 @@ const Likes = world.entity()
|
||||||
const bob = world.entity()
|
const bob = world.entity()
|
||||||
for (const [_] of world.query(pair(Likes, bob))) {}
|
for (const [_] of world.query(pair(Likes, bob))) {}
|
||||||
```
|
```
|
||||||
|
:::
|
||||||
|
|
||||||
When a query pair contains a wildcard, the `world:target()` function can be used to determine the target of the pair element that matched the query:
|
When a query pair contains a wildcard, the `world:target()` function can be used to determine the target of the pair element that matched the query:
|
||||||
|
|
||||||
|
@ -87,6 +89,7 @@ for (const [_] of world.query(pair(Likes, jecs.Wildcard))) {
|
||||||
print(`entity ${getName(id)} likes ${getName(world.target(id, Likes))}`)
|
print(`entity ${getName(id)} likes ${getName(world.target(id, Likes))}`)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
:::
|
||||||
|
|
||||||
### Filters
|
### Filters
|
||||||
Filters are extensions to queries which allow you to select entities from a more complex pattern but you don't actually care about the component values.
|
Filters are extensions to queries which allow you to select entities from a more complex pattern but you don't actually care about the component values.
|
||||||
|
|
Loading…
Reference in a new issue