Skip to content

Commit 2917373

Browse files
committed
Merch branch
2 parents 51c8ae6 + a3eb2cd commit 2917373

File tree

14 files changed

+305
-164
lines changed

14 files changed

+305
-164
lines changed

benches/query.luau

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ do
4040
end
4141
end)
4242

43-
BENCH("1 component, 7 tags", function()
44-
for _ in world:query(H):with(G, F, E, D, C, B, A) do
45-
end
46-
end)
47-
4843
local e = world:entity()
4944
world:set(e, A, true)
5045
world:set(e, B, true)

docs/.vitepress/config.mts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default defineConfig({
99
// https://vitepress.dev/reference/default-theme-config
1010
nav: [
1111
{ text: 'Home', link: '/' },
12+
<<<<<<< HEAD
1213
{ text: 'Examples', link: '/markdown-examples' }
1314
],
1415

@@ -50,6 +51,59 @@ export default defineConfig({
5051
}
5152
],
5253

54+
=======
55+
{ text: 'Examples', link: '/markdown-examples' },
56+
{ text: 'API', link: '/api/jecs.md' }
57+
],
58+
59+
sidebar: {
60+
"/api/": [
61+
{
62+
text: "API reference",
63+
items: [
64+
{ text: "jecs", link: "/api/jecs" },
65+
{ text: "World", link: "/api/world" },
66+
{ text: "Query", link: "/api/query" }
67+
]
68+
}
69+
],
70+
"/learn/": [
71+
{
72+
text: "Introduction",
73+
items: [
74+
{ text: 'Getting Started', link: '/overview/get-started' },
75+
{ text: 'First Jecs Project', link: '/overview/first-jecs-project' }
76+
]
77+
},
78+
{
79+
text: 'Concepts',
80+
items: [
81+
{ text: 'Entities', link: '/concepts/entities' },
82+
{ text: 'Static Components', link: '/concepts/static-components' },
83+
{ text: 'Queries', link: '/concepts/queries' },
84+
]
85+
},
86+
{
87+
text: "FAQ",
88+
items: [
89+
{ text: 'How can I contribute?', link: '/faq/contributing' }
90+
]
91+
},
92+
93+
],
94+
"/contributing/": [
95+
{
96+
text: 'Contributing',
97+
items: [
98+
{ text: 'Contribution Guidelines', link: '/contributing/guidelines' },
99+
{ text: 'Submitting Issues', link: '/contributing/issues' },
100+
{ text: 'Submitting Pull Requests', link: '/contributing/pull-requests' },
101+
]
102+
}
103+
]
104+
},
105+
106+
>>>>>>> a3eb2cddc35a58d42ed468f8a5806597f709345e
53107
socialLinks: [
54108
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }
55109
]

docs/api/jecs.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Jecs
2+
3+
Jecs. Just an Entity Component System.
4+
5+
## Properties
6+
7+
### World
8+
```luau
9+
jecs.World: World
10+
```
11+
12+
### Wildcard
13+
14+
### z<>
15+
16+
## Functions
17+
18+
### pair()
19+
```luau
20+
function jecs.pair(
21+
first: Entity, -- The first element of the pair, referred to as the relationship of the relationship pair.
22+
object: Entity, -- The second element of the pair, referred to as the target of the relationship pair.
23+
): number -- Returns the Id with those two elements
24+
25+
```
26+
::: info
27+
28+
Note that while relationship pairs can be used as components, meaning you can add data with it as an ID, however they cannot be used as entities. Meaning you cannot add components to a pair as the source of a binding.
29+
30+
:::

docs/api/world.md

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# World
1+
# Query
22

33
A World contains entities which have components. The World is queryable and can be used to get entities with a specific set of components.
44

55
## Functions
66

77
### new()
8-
```lua
8+
```luau
99
function World.new(): World
1010
```
1111
Creates a new world.
@@ -27,7 +27,7 @@ const world = new World();
2727

2828
## entity()
2929
```luau
30-
function World:entity(): Entity
30+
function World:entity(): Entity -- The new entit.
3131
```
3232
Creates a new entity.
3333

@@ -42,11 +42,12 @@ local entity = world:entity()
4242
const entity = world.entity();
4343
```
4444

45-
:::
45+
::
46+
:
4647

47-
### component()`
48+
### component()
4849
```luau
49-
function World:component<T>(): Entity<T>
50+
function World:component<T>(): Entity<T> -- The new componen.
5051
```
5152
Creates a new component.
5253

@@ -60,11 +61,72 @@ local Health = world:component() :: jecs.Entity<number>
6061
```ts [typescript]
6162
const Health = world.component<number>();
6263
```
63-
6464
:::
6565

6666
::: info
6767
You should use this when creating components.
6868

6969
For example, a Health type should be created using this.
7070
:::
71+
72+
### get()
73+
```luau
74+
function World:get(
75+
entity: Entity, -- The entity
76+
...: Entity<T> -- The types to fetch
77+
): ... -- Returns the component data in the same order they were passed in
78+
```
79+
Returns the data for each provided type for the corresponding entity.
80+
81+
:::
82+
83+
### add()
84+
```luau
85+
function World:add(
86+
entity: Entity, -- The entity
87+
id: Entity<T> -- The component ID to add
88+
): ()
89+
```
90+
Adds a component ID to the entity.
91+
92+
This operation adds a single (component) id to an entity.
93+
94+
::: info
95+
This function is idempotent, meaning if the entity already has the id, this operation will have no side effects.
96+
:::
97+
98+
99+
### set()
100+
```luau
101+
function World:set(
102+
entity: Entity, -- The entity
103+
id: Entity<T>, -- The component ID to set
104+
data: T -- The data of the component's type
105+
): ()
106+
```
107+
Adds or changes the entity's component.
108+
109+
### query()
110+
```luau
111+
function World:query(
112+
...: Entity<T> -- The component IDs to query with. Entities that satifies the conditions will be returned
113+
): Query<...Entity<T>> -- Returns the Query which gets the entity and their corresponding data when iterated
114+
```
115+
Creates a [`query`](query) with the given component IDs.
116+
117+
Example:
118+
::: code-group
119+
120+
```luau [luau]
121+
for id, position, velocity in world:query(Position, Velocity) do
122+
-- Do something
123+
end
124+
```
125+
126+
```ts [typescript]
127+
for (const [id, position, velocity] of world.query(Position, Velocity) {
128+
// Do something
129+
}
130+
```
131+
132+
:::

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ hero:
1414
link: /overview/get-started.md
1515
- theme: alt
1616
text: API References
17-
link: /api/
17+
link: /api/jecs.md
1818

1919
features:
2020
- title: Stupidly Fast
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1+
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
## TODO
2-
1+
## TODO
2+
33
This is a TODO stub.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
## TODO
2-
1+
## TODO
2+
33
This is a TODO stub.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
## TODO
2-
1+
## TODO
2+
33
This is a TODO stub.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
## TODO
2-
1+
## TODO
2+
33
This is a TODO stub.

0 commit comments

Comments
 (0)