@origingame/engine 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/og.mjs +25 -0
- package/dist/web/origin-engine.d.ts +1233 -0
- package/dist/web/origin-engine.js +8628 -0
- package/dist/web/origin-engine_bg.wasm +0 -0
- package/dist/web/origin-engine_bg.wasm.d.ts +366 -0
- package/dist/web-publish/origin-engine-lanes.js +8509 -0
- package/dist/web-publish/origin-engine-lanes_bg.wasm +0 -0
- package/dist/web-publish/origin-engine.d.ts +1176 -0
- package/dist/web-publish/origin-engine.js +8313 -0
- package/dist/web-publish/origin-engine_bg.wasm +0 -0
- package/dist/web-publish/origin-engine_bg.wasm.d.ts +347 -0
- package/dist/web-publish/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.no-bundler.js +77 -0
- package/dist/web-publish-2d/origin-engine-lanes.js +8509 -0
- package/dist/web-publish-2d/origin-engine-lanes_bg.wasm +0 -0
- package/dist/web-publish-2d/origin-engine.d.ts +1176 -0
- package/dist/web-publish-2d/origin-engine.js +8313 -0
- package/dist/web-publish-2d/origin-engine_bg.wasm +0 -0
- package/dist/web-publish-2d/origin-engine_bg.wasm.d.ts +347 -0
- package/dist/web-publish-2d/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.no-bundler.js +77 -0
- package/knowledge/README.md +31 -0
- package/knowledge/knowledge.json +13 -0
- package/knowledge/looks/catalogue.json +1871 -0
- package/knowledge/package.json +33 -0
- package/knowledge/rules/platform.json +329 -0
- package/knowledge/scaffold/README.md +27 -0
- package/knowledge/scaffold/distribution.json +48 -0
- package/knowledge/scaffold/origin-engine.json +19 -0
- package/knowledge/scaffold/template/.origin/setup +14 -0
- package/knowledge/scaffold/template/LICENSES.md +23 -0
- package/knowledge/scaffold/template/README.md +37 -0
- package/knowledge/scaffold/template/assets/ai/guard.ogt +48 -0
- package/knowledge/scaffold/template/assets/audio/click.ogt +9 -0
- package/knowledge/scaffold/template/assets/fonts/NotoSansSC-Regular-subset.ttf.ogt +12 -0
- package/knowledge/scaffold/template/assets/fonts/OFL.txt +93 -0
- package/knowledge/scaffold/template/assets/looks/origin-game.ogt +12 -0
- package/knowledge/scaffold/template/assets/nav/yard.ogt +27 -0
- package/knowledge/scaffold/template/assets/scenes/main.ogt +34 -0
- package/knowledge/scaffold/template/assets/strings/en.ogt +14 -0
- package/knowledge/scaffold/template/assets/textures/stone_n.png.ogt +7 -0
- package/knowledge/scaffold/template/gitattributes +22 -0
- package/knowledge/scaffold/template/gitignore +8 -0
- package/knowledge/scaffold/template/package.json +18 -0
- package/knowledge/scaffold/template/project.ogt +25 -0
- package/knowledge/scaffold/template/src/main.ts +246 -0
- package/knowledge/scaffold/template/tests/guard.og.ts +67 -0
- package/knowledge/scaffold/template/tests/smoke.og.ts +43 -0
- package/knowledge/scaffold/template/tsconfig.json +17 -0
- package/knowledge/scripts/lib.ts +207 -0
- package/knowledge/scripts/mount.ts +210 -0
- package/knowledge/scripts/pack.ts +25 -0
- package/knowledge/scripts/scaffold.ts +72 -0
- package/knowledge/scripts/validate.ts +749 -0
- package/knowledge/skills/og-ai/SKILL.md +386 -0
- package/knowledge/skills/og-audio/SKILL.md +191 -0
- package/knowledge/skills/og-build/SKILL.md +330 -0
- package/knowledge/skills/og-core/SKILL.md +285 -0
- package/knowledge/skills/og-feel/SKILL.md +385 -0
- package/knowledge/skills/og-game/SKILL.md +1479 -0
- package/knowledge/skills/og-i18n/SKILL.md +220 -0
- package/knowledge/skills/og-platform-sdk/SKILL.md +199 -0
- package/knowledge/skills/og-taste/SKILL.md +537 -0
- package/knowledge/skills/og-ui/SKILL.md +444 -0
- package/knowledge/wiki/ai.md +627 -0
- package/knowledge/wiki/anim.md +1187 -0
- package/knowledge/wiki/atmosphere.md +636 -0
- package/knowledge/wiki/audio.md +732 -0
- package/knowledge/wiki/camera.md +711 -0
- package/knowledge/wiki/commands.md +357 -0
- package/knowledge/wiki/game.md +220 -0
- package/knowledge/wiki/i18n.md +213 -0
- package/knowledge/wiki/index.md +1027 -0
- package/knowledge/wiki/input.md +1714 -0
- package/knowledge/wiki/load.md +1280 -0
- package/knowledge/wiki/math.md +166 -0
- package/knowledge/wiki/nav.md +1154 -0
- package/knowledge/wiki/physics.md +3142 -0
- package/knowledge/wiki/platform.md +857 -0
- package/knowledge/wiki/probe.md +1692 -0
- package/knowledge/wiki/reflect.md +285 -0
- package/knowledge/wiki/render.md +3511 -0
- package/knowledge/wiki/rng.md +393 -0
- package/knowledge/wiki/stream.md +376 -0
- package/knowledge/wiki/system.md +197 -0
- package/knowledge/wiki/systems.md +43 -0
- package/knowledge/wiki/terrain.md +727 -0
- package/knowledge/wiki/tilemap.md +422 -0
- package/knowledge/wiki/time.md +150 -0
- package/knowledge/wiki/transform.md +230 -0
- package/knowledge/wiki/tween.md +580 -0
- package/knowledge/wiki/ui.md +8000 -0
- package/knowledge/wiki/world.md +909 -0
- package/package.json +68 -4
- package/schema/api.schema.json +29675 -0
- package/shell/README.md +22 -0
- package/shell/brand/README.md +23 -0
- package/shell/brand/icon-192.png +0 -0
- package/shell/brand/icon-512.png +0 -0
- package/shell/brand/mark-on-paper.svg +6 -0
- package/shell/brand/origin-mark.svg +5 -0
- package/shell/brand/origin-motion.css +251 -0
- package/shell/brand/tokens.css +20 -0
- package/shell/brand.ts +132 -0
- package/shell/page.ts +715 -0
- package/shell/platform.ts +203 -0
- package/shell/player.ts +238 -0
- package/shell/shell.css +185 -0
- package/shell/sw.ts +177 -0
- package/shell/transport.ts +515 -0
- package/shell/wire.ts +369 -0
- package/src/e6.ts +69 -0
- package/src/env.d.ts +100 -0
- package/src/generated/abi.ts +980 -0
- package/src/index.ts +193 -0
- package/src/node/audio.ts +86 -0
- package/src/node/build.ts +109 -0
- package/src/node/device.ts +981 -0
- package/src/node/doctor.ts +60 -0
- package/src/node/index.ts +102 -0
- package/src/node/platform.ts +24 -0
- package/src/node/playtest-run.ts +249 -0
- package/src/node/png.ts +130 -0
- package/src/node/polish.ts +976 -0
- package/src/node/run.ts +373 -0
- package/src/node/web-build.ts +808 -0
- package/src/p2.ts +35 -0
- package/src/platform-local.ts +211 -0
- package/src/playtest.ts +131 -0
- package/src/runtime.ts +1509 -0
- package/src/systems/cameras.ts +247 -0
- package/src/ui-kit/bind.ts +141 -0
- package/src/ui-kit/huds.ts +303 -0
- package/src/ui-kit/index.ts +36 -0
- package/src/ui-kit/menus.ts +187 -0
- package/src/ui-kit/settings.ts +131 -0
- package/src/ui-kit/store.ts +222 -0
- package/src/ui-kit/story.ts +89 -0
- package/src/ui-kit/util.ts +106 -0
- package/src/web/a11y.ts +429 -0
- package/src/web/audio-worklet.ts +193 -0
- package/src/web/audio.ts +307 -0
- package/src/web/basis.ts +239 -0
- package/src/web/gamepad.ts +123 -0
- package/src/web/host.ts +166 -0
- package/src/web/input.ts +237 -0
- package/src/web/lanes.ts +21 -0
- package/src/web/play.ts +20 -0
- package/src/web/rpc-ring.ts +110 -0
- package/src/web/settle.ts +122 -0
- package/src/web/shell.ts +643 -0
- package/src/web/text-input.ts +248 -0
- package/src/web/worker.ts +1002 -0
- package/types/bindings.json +13654 -0
- package/types/index.d.ts +20090 -0
- package/vendor/basis/LICENSE +201 -0
- package/vendor/basis/NOTICE +15 -0
- package/vendor/basis/README.md +18 -0
- package/vendor/basis/basis_transcoder.js +19 -0
- package/vendor/basis/basis_transcoder.wasm +0 -0
- package/README.md +0 -3
|
@@ -0,0 +1,909 @@
|
|
|
1
|
+
<!-- Generated from crates/og-api/api.ogt by `og api gen`. Do not edit: `og api check` fails on any difference; change api.ogt and regenerate. -->
|
|
2
|
+
|
|
3
|
+
# The `world` module
|
|
4
|
+
|
|
5
|
+
The world: an archetype ECS. Entities are generational handles; components are columns in engine memory.
|
|
6
|
+
|
|
7
|
+
Structural changes (spawn, despawn, insert, remove) invalidate typed views; the API refuses a stale view.
|
|
8
|
+
|
|
9
|
+
- **TypeScript**: functions are none at module level (its members live on the types below); components, resources and events are tokens on `og`.
|
|
10
|
+
- **Publish builds**: kept (members may override).
|
|
11
|
+
- **Skill**: `og-core`, which teaches the module (how much of it to use, and how to prove it).
|
|
12
|
+
- **Index**: [every module and name](index.md).
|
|
13
|
+
|
|
14
|
+
```ogt
|
|
15
|
+
module world {
|
|
16
|
+
# declarations follow, each quoted below
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
<sub>`api.ogt` line 204</sub>
|
|
20
|
+
|
|
21
|
+
## Contents
|
|
22
|
+
|
|
23
|
+
| Name | Kind | Summary |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| [`Entity`](#type-Entity) | handle | An entity: an index and a generation. The value is index + generation * 2^32, with the generation below 2^21, so it stays an exact JavaScript number. |
|
|
26
|
+
| [`Entity()`](#column-Entity) | column kind | An Entity field: (index, generation) pairs. |
|
|
27
|
+
| [`SpawnDesc`](#type-SpawnDesc) | desc struct | How to spawn an entity. `{}` spawns an unnamed entity at the origin with a Transform. |
|
|
28
|
+
| [`RestoreDesc`](#type-RestoreDesc) | desc struct | How world.restore takes a save. |
|
|
29
|
+
| [`QueryDesc`](#type-QueryDesc) | desc struct | Which entities a query matches. |
|
|
30
|
+
| [`World`](#type-World) | interface | The world a system, a command or a game callback is handed. Game code never holds a world beyond the call it was passed to. |
|
|
31
|
+
| [`Query`](#type-Query) | interface | A set of matched archetypes. Iterate archetypes, never entities one by one. |
|
|
32
|
+
| [`ArchetypeView`](#type-ArchetypeView) | interface | One archetype's columns for this tick. Views are invalidated by structural changes; using a stale view throws with the tick and the system it belonged to. |
|
|
33
|
+
|
|
34
|
+
## Interfaces
|
|
35
|
+
|
|
36
|
+
<a id="type-World"></a>
|
|
37
|
+
|
|
38
|
+
### `World` (interface)
|
|
39
|
+
|
|
40
|
+
The world a system, a command or a game callback is handed. Game code never holds a world beyond the call it was passed to.
|
|
41
|
+
|
|
42
|
+
```ogt
|
|
43
|
+
interface World {
|
|
44
|
+
doc "The world a system, a command or a game callback is handed. Game code never holds a world beyond the call it was passed to."
|
|
45
|
+
# members follow, each quoted below
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
<sub>`api.ogt` line 249</sub>
|
|
49
|
+
|
|
50
|
+
<a id="member-World-tick"></a>
|
|
51
|
+
|
|
52
|
+
#### `World.tick` (property)
|
|
53
|
+
|
|
54
|
+
Fixed steps taken since the world was created.
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
readonly tick: number
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Binding symbol `og_world_get_tick` · publish builds: kept
|
|
61
|
+
|
|
62
|
+
```ogt
|
|
63
|
+
prop tick u32 "Fixed steps taken since the world was created."
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
<sub>`api.ogt` line 252</sub>
|
|
67
|
+
|
|
68
|
+
<a id="member-World-spawn"></a>
|
|
69
|
+
|
|
70
|
+
#### `World.spawn`
|
|
71
|
+
|
|
72
|
+
Spawn an entity.
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
World.spawn(desc?: SpawnDesc): Result<Entity>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
| Parameter | Type | Optional | Doc |
|
|
79
|
+
|---|---|---|---|
|
|
80
|
+
| `desc` | `SpawnDesc` | yes | Name, parent and initial transform. |
|
|
81
|
+
|
|
82
|
+
**Returns** `Result<Entity>`: The new entity, or why it was refused (a duplicate name, a dead parent).
|
|
83
|
+
|
|
84
|
+
Binding symbol `og_world_spawn` · publish builds: kept
|
|
85
|
+
|
|
86
|
+
```ogt
|
|
87
|
+
fn spawn {
|
|
88
|
+
doc "Spawn an entity."
|
|
89
|
+
param desc SpawnDesc "Name, parent and initial transform."
|
|
90
|
+
returns Result.Entity "The new entity, or why it was refused (a duplicate name, a dead parent)."
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
<sub>`api.ogt` line 254</sub>
|
|
95
|
+
|
|
96
|
+
<a id="member-World-despawn"></a>
|
|
97
|
+
|
|
98
|
+
#### `World.despawn`
|
|
99
|
+
|
|
100
|
+
Despawn an entity and its descendants.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
World.despawn(entity: Entity): Result<void>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
| Parameter | Type | Optional | Doc |
|
|
107
|
+
|---|---|---|---|
|
|
108
|
+
| `entity` | `Entity` | no | The entity. |
|
|
109
|
+
|
|
110
|
+
**Returns** `Result<void>`: Refused for a dead entity.
|
|
111
|
+
|
|
112
|
+
Binding symbol `og_world_despawn` · publish builds: kept
|
|
113
|
+
|
|
114
|
+
```ogt
|
|
115
|
+
fn despawn {
|
|
116
|
+
doc "Despawn an entity and its descendants."
|
|
117
|
+
param entity Entity "The entity."
|
|
118
|
+
returns Result.Void "Refused for a dead entity."
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
<sub>`api.ogt` line 260</sub>
|
|
123
|
+
|
|
124
|
+
<a id="member-World-alive"></a>
|
|
125
|
+
|
|
126
|
+
#### `World.alive`
|
|
127
|
+
|
|
128
|
+
Whether an entity handle is live.
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
World.alive(entity: Entity): boolean
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
| Parameter | Type | Optional | Doc |
|
|
135
|
+
|---|---|---|---|
|
|
136
|
+
| `entity` | `Entity` | no | The entity. |
|
|
137
|
+
|
|
138
|
+
**Returns** `boolean`.
|
|
139
|
+
|
|
140
|
+
Binding symbol `og_world_alive` · publish builds: kept
|
|
141
|
+
|
|
142
|
+
```ogt
|
|
143
|
+
fn alive {
|
|
144
|
+
doc "Whether an entity handle is live."
|
|
145
|
+
param entity Entity "The entity."
|
|
146
|
+
returns bool
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
<sub>`api.ogt` line 266</sub>
|
|
151
|
+
|
|
152
|
+
<a id="member-World-has"></a>
|
|
153
|
+
|
|
154
|
+
#### `World.has`
|
|
155
|
+
|
|
156
|
+
Whether an entity has a component.
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
World.has<C extends AnyComponent>(entity: Entity, component: C): boolean
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
| Parameter | Type | Optional | Doc |
|
|
163
|
+
|---|---|---|---|
|
|
164
|
+
| `entity` | `Entity` | no | The entity. |
|
|
165
|
+
| `component` | `C` | no | The component token. |
|
|
166
|
+
|
|
167
|
+
**Returns** `boolean`.
|
|
168
|
+
|
|
169
|
+
Binding symbol `og_world_has` · publish builds: kept
|
|
170
|
+
|
|
171
|
+
```ogt
|
|
172
|
+
fn has {
|
|
173
|
+
doc "Whether an entity has a component."
|
|
174
|
+
generic C AnyComponent
|
|
175
|
+
param entity Entity "The entity."
|
|
176
|
+
param component C "The component token."
|
|
177
|
+
returns bool
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
<sub>`api.ogt` line 272</sub>
|
|
182
|
+
|
|
183
|
+
<a id="member-World-insert"></a>
|
|
184
|
+
|
|
185
|
+
#### `World.insert`
|
|
186
|
+
|
|
187
|
+
Add a component to an entity, or overwrite it when present. A structural change.
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
World.insert<C extends AnyComponent>(entity: Entity, component: C, value?: Partial<Value<C>>): Result<void>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
| Parameter | Type | Optional | Doc |
|
|
194
|
+
|---|---|---|---|
|
|
195
|
+
| `entity` | `Entity` | no | The entity. |
|
|
196
|
+
| `component` | `C` | no | The component token. |
|
|
197
|
+
| `value` | `Partial<Value<C>>` | yes | Field values; omitted fields take their defaults. |
|
|
198
|
+
|
|
199
|
+
**Returns** `Result<void>`: Refused for a dead entity or an unregistered component.
|
|
200
|
+
|
|
201
|
+
Binding symbol `og_world_insert` · publish builds: kept
|
|
202
|
+
|
|
203
|
+
```ogt
|
|
204
|
+
fn insert {
|
|
205
|
+
doc "Add a component to an entity, or overwrite it when present. A structural change."
|
|
206
|
+
generic C AnyComponent
|
|
207
|
+
param entity Entity "The entity."
|
|
208
|
+
param component C "The component token."
|
|
209
|
+
param value Partial.Value.C "Field values; omitted fields take their defaults." {
|
|
210
|
+
optional true
|
|
211
|
+
}
|
|
212
|
+
returns Result.Void "Refused for a dead entity or an unregistered component."
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
<sub>`api.ogt` line 280</sub>
|
|
217
|
+
|
|
218
|
+
<a id="member-World-remove"></a>
|
|
219
|
+
|
|
220
|
+
#### `World.remove`
|
|
221
|
+
|
|
222
|
+
Remove a component from an entity. A structural change.
|
|
223
|
+
|
|
224
|
+
```ts
|
|
225
|
+
World.remove<C extends AnyComponent>(entity: Entity, component: C): Result<void>
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
| Parameter | Type | Optional | Doc |
|
|
229
|
+
|---|---|---|---|
|
|
230
|
+
| `entity` | `Entity` | no | The entity. |
|
|
231
|
+
| `component` | `C` | no | The component token. |
|
|
232
|
+
|
|
233
|
+
**Returns** `Result<void>`: Refused for a dead entity or a component it does not have.
|
|
234
|
+
|
|
235
|
+
Binding symbol `og_world_remove` · publish builds: kept
|
|
236
|
+
|
|
237
|
+
```ogt
|
|
238
|
+
fn remove {
|
|
239
|
+
doc "Remove a component from an entity. A structural change."
|
|
240
|
+
generic C AnyComponent
|
|
241
|
+
param entity Entity "The entity."
|
|
242
|
+
param component C "The component token."
|
|
243
|
+
returns Result.Void "Refused for a dead entity or a component it does not have."
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
<sub>`api.ogt` line 291</sub>
|
|
248
|
+
|
|
249
|
+
<a id="member-World-get"></a>
|
|
250
|
+
|
|
251
|
+
#### `World.get`
|
|
252
|
+
|
|
253
|
+
Copy one entity's component value. For bulk work use a system's typed views.
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
World.get<C extends AnyComponent>(entity: Entity, component: C): Result<Value<C>>
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
| Parameter | Type | Optional | Doc |
|
|
260
|
+
|---|---|---|---|
|
|
261
|
+
| `entity` | `Entity` | no | The entity. |
|
|
262
|
+
| `component` | `C` | no | The component token. |
|
|
263
|
+
|
|
264
|
+
**Returns** `Result<Value<C>>`.
|
|
265
|
+
|
|
266
|
+
Binding symbol `og_world_get` · publish builds: kept
|
|
267
|
+
|
|
268
|
+
```ogt
|
|
269
|
+
fn get {
|
|
270
|
+
doc "Copy one entity's component value. For bulk work use a system's typed views."
|
|
271
|
+
generic C AnyComponent
|
|
272
|
+
param entity Entity "The entity."
|
|
273
|
+
param component C "The component token."
|
|
274
|
+
returns Result.Value.C
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
<sub>`api.ogt` line 299</sub>
|
|
279
|
+
|
|
280
|
+
<a id="member-World-set"></a>
|
|
281
|
+
|
|
282
|
+
#### `World.set`
|
|
283
|
+
|
|
284
|
+
Write some fields of one entity's component.
|
|
285
|
+
|
|
286
|
+
```ts
|
|
287
|
+
World.set<C extends AnyComponent>(entity: Entity, component: C, value: Partial<Value<C>>): Result<void>
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
| Parameter | Type | Optional | Doc |
|
|
291
|
+
|---|---|---|---|
|
|
292
|
+
| `entity` | `Entity` | no | The entity. |
|
|
293
|
+
| `component` | `C` | no | The component token. |
|
|
294
|
+
| `value` | `Partial<Value<C>>` | no | The fields to write. |
|
|
295
|
+
|
|
296
|
+
**Returns** `Result<void>`: Refused for a dead entity or a component it does not have.
|
|
297
|
+
|
|
298
|
+
Binding symbol `og_world_set` · publish builds: kept
|
|
299
|
+
|
|
300
|
+
```ogt
|
|
301
|
+
fn set {
|
|
302
|
+
doc "Write some fields of one entity's component."
|
|
303
|
+
generic C AnyComponent
|
|
304
|
+
param entity Entity "The entity."
|
|
305
|
+
param component C "The component token."
|
|
306
|
+
param value Partial.Value.C "The fields to write."
|
|
307
|
+
returns Result.Void "Refused for a dead entity or a component it does not have."
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
<sub>`api.ogt` line 307</sub>
|
|
312
|
+
|
|
313
|
+
<a id="member-World-resource"></a>
|
|
314
|
+
|
|
315
|
+
#### `World.resource`
|
|
316
|
+
|
|
317
|
+
A resource's live value: the same handle in a world every time, its fields typed reads and writes of the resource's packed record (no JSON, whatever its size). The record is fetched again only by the first read after another engine call or a system boundary, and writes reach the engine in one call before the next engine call and when the system or command returns, so two handles agree and a read after an engine call sees the engine's value (og-core §4). Inside a system, the resource must be among the system's reads or writes (writes to set a field): an undeclared one throws in a dev or release build, naming the system and the resource, and fails the tick; a publish build refuses it and logs it once per system in the engine log.
|
|
318
|
+
|
|
319
|
+
```ts
|
|
320
|
+
World.resource<R extends AnyResource>(resource: R): Result<Value<R>>
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
| Parameter | Type | Optional | Doc |
|
|
324
|
+
|---|---|---|---|
|
|
325
|
+
| `resource` | `R` | no | The resource token. |
|
|
326
|
+
|
|
327
|
+
**Returns** `Result<Value<R>>`: Refused for an unregistered resource (or, in a publish build, one the running system did not declare).
|
|
328
|
+
|
|
329
|
+
Binding symbol `og_world_resource` · publish builds: kept
|
|
330
|
+
|
|
331
|
+
```ogt
|
|
332
|
+
fn resource {
|
|
333
|
+
doc "A resource's live value: the same handle in a world every time, its fields typed reads and writes of the resource's packed record (no JSON, whatever its size). The record is fetched again only by the first read after another engine call or a system boundary, and writes reach the engine in one call before the next engine call and when the system or command returns, so two handles agree and a read after an engine call sees the engine's value (og-core §4). Inside a system, the resource must be among the system's reads or writes (writes to set a field): an undeclared one throws in a dev or release build, naming the system and the resource, and fails the tick; a publish build refuses it and logs it once per system in the engine log."
|
|
334
|
+
generic R AnyResource
|
|
335
|
+
param resource R "The resource token."
|
|
336
|
+
returns Result.Value.R "Refused for an unregistered resource (or, in a publish build, one the running system did not declare)."
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
<sub>`api.ogt` line 316</sub>
|
|
341
|
+
|
|
342
|
+
<a id="member-World-find"></a>
|
|
343
|
+
|
|
344
|
+
#### `World.find`
|
|
345
|
+
|
|
346
|
+
The entity with a name.
|
|
347
|
+
|
|
348
|
+
```ts
|
|
349
|
+
World.find(name: string): Entity | null
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
| Parameter | Type | Optional | Doc |
|
|
353
|
+
|---|---|---|---|
|
|
354
|
+
| `name` | `string` | no | The name given at spawn. |
|
|
355
|
+
|
|
356
|
+
**Returns** `Entity | null`: Null when no live entity has the name.
|
|
357
|
+
|
|
358
|
+
Binding symbol `og_world_find` · publish builds: kept
|
|
359
|
+
|
|
360
|
+
```ogt
|
|
361
|
+
fn find {
|
|
362
|
+
doc "The entity with a name."
|
|
363
|
+
param name String "The name given at spawn."
|
|
364
|
+
returns Option.Entity "Null when no live entity has the name."
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
<sub>`api.ogt` line 323</sub>
|
|
369
|
+
|
|
370
|
+
<a id="member-World-nameOf"></a>
|
|
371
|
+
|
|
372
|
+
#### `World.nameOf`
|
|
373
|
+
|
|
374
|
+
An entity's name.
|
|
375
|
+
|
|
376
|
+
```ts
|
|
377
|
+
World.nameOf(entity: Entity): string | null
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
| Parameter | Type | Optional | Doc |
|
|
381
|
+
|---|---|---|---|
|
|
382
|
+
| `entity` | `Entity` | no | The entity. |
|
|
383
|
+
|
|
384
|
+
**Returns** `string | null`: Null for an unnamed or dead entity.
|
|
385
|
+
|
|
386
|
+
Binding symbol `og_world_name_of` · publish builds: kept
|
|
387
|
+
|
|
388
|
+
```ogt
|
|
389
|
+
fn nameOf {
|
|
390
|
+
doc "An entity's name."
|
|
391
|
+
param entity Entity "The entity."
|
|
392
|
+
returns Option.String "Null for an unnamed or dead entity."
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
<sub>`api.ogt` line 329</sub>
|
|
397
|
+
|
|
398
|
+
<a id="member-World-query"></a>
|
|
399
|
+
|
|
400
|
+
#### `World.query`
|
|
401
|
+
|
|
402
|
+
A query over the current archetypes, for commands and callbacks (GameDesc.start, a command, a UI callback). Inside a system it is refused, by design: a system receives its one query (every component of its reads and writes) as its first argument; loop over another archetype in a system of its own.
|
|
403
|
+
|
|
404
|
+
```ts
|
|
405
|
+
World.query(desc?: QueryDesc): Result<Query>
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
| Parameter | Type | Optional | Doc |
|
|
409
|
+
|---|---|---|---|
|
|
410
|
+
| `desc` | `QueryDesc` | yes | The components to match. |
|
|
411
|
+
|
|
412
|
+
**Returns** `Result<Query>`.
|
|
413
|
+
|
|
414
|
+
Binding symbol `og_world_query` · publish builds: kept
|
|
415
|
+
|
|
416
|
+
```ogt
|
|
417
|
+
fn query {
|
|
418
|
+
doc "A query over the current archetypes, for commands and callbacks (GameDesc.start, a command, a UI callback). Inside a system it is refused, by design: a system receives its one query (every component of its reads and writes) as its first argument; loop over another archetype in a system of its own."
|
|
419
|
+
param desc QueryDesc "The components to match."
|
|
420
|
+
returns Result.Query
|
|
421
|
+
}
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
<sub>`api.ogt` line 335</sub>
|
|
425
|
+
|
|
426
|
+
<a id="member-World-events"></a>
|
|
427
|
+
|
|
428
|
+
#### `World.events`
|
|
429
|
+
|
|
430
|
+
The events of one type emitted during the previous tick and this one, oldest first. Inside a system the event must be among its reads or writes (undeclared: thrown, or in a publish build refused and logged once).
|
|
431
|
+
|
|
432
|
+
```ts
|
|
433
|
+
World.events<E extends AnyEvent>(event: E): readonly Value<E>[]
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
| Parameter | Type | Optional | Doc |
|
|
437
|
+
|---|---|---|---|
|
|
438
|
+
| `event` | `E` | no | The event token. |
|
|
439
|
+
|
|
440
|
+
**Returns** `readonly Value<E>[]`.
|
|
441
|
+
|
|
442
|
+
Binding symbol `og_world_events` · publish builds: kept
|
|
443
|
+
|
|
444
|
+
```ogt
|
|
445
|
+
fn events {
|
|
446
|
+
doc "The events of one type emitted during the previous tick and this one, oldest first. Inside a system the event must be among its reads or writes (undeclared: thrown, or in a publish build refused and logged once)."
|
|
447
|
+
generic E AnyEvent
|
|
448
|
+
param event E "The event token."
|
|
449
|
+
returns List.Value.E
|
|
450
|
+
}
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
<sub>`api.ogt` line 341</sub>
|
|
454
|
+
|
|
455
|
+
<a id="member-World-emit"></a>
|
|
456
|
+
|
|
457
|
+
#### `World.emit`
|
|
458
|
+
|
|
459
|
+
Emit an event; readers see it this tick and the next. Inside a system the event must be among its writes (undeclared: thrown, or in a publish build refused and logged once).
|
|
460
|
+
|
|
461
|
+
```ts
|
|
462
|
+
World.emit<E extends AnyEvent>(event: E, payload: Value<E>): Result<void>
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
| Parameter | Type | Optional | Doc |
|
|
466
|
+
|---|---|---|---|
|
|
467
|
+
| `event` | `E` | no | The event token. |
|
|
468
|
+
| `payload` | `Value<E>` | no | The event's fields. |
|
|
469
|
+
|
|
470
|
+
**Returns** `Result<void>`.
|
|
471
|
+
|
|
472
|
+
Binding symbol `og_world_emit` · publish builds: kept
|
|
473
|
+
|
|
474
|
+
```ogt
|
|
475
|
+
fn emit {
|
|
476
|
+
doc "Emit an event; readers see it this tick and the next. Inside a system the event must be among its writes (undeclared: thrown, or in a publish build refused and logged once)."
|
|
477
|
+
generic E AnyEvent
|
|
478
|
+
param event E "The event token."
|
|
479
|
+
param payload Value.E "The event's fields."
|
|
480
|
+
returns Result.Void
|
|
481
|
+
}
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
<sub>`api.ogt` line 348</sub>
|
|
485
|
+
|
|
486
|
+
<a id="member-World-instantiate"></a>
|
|
487
|
+
|
|
488
|
+
#### `World.instantiate`
|
|
489
|
+
|
|
490
|
+
Spawn a loaded scene or glTF asset into the world: a root entity from the desc, then (for a scene) every scene entity under it with its components and names, or (for a glTF) a Model on the root.
|
|
491
|
+
|
|
492
|
+
Scene entity names must be free: a name already in use refuses the whole instantiation before anything spawns.
|
|
493
|
+
|
|
494
|
+
```ts
|
|
495
|
+
World.instantiate(asset: Asset, desc?: SpawnDesc): Result<Entity>
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
| Parameter | Type | Optional | Doc |
|
|
499
|
+
|---|---|---|---|
|
|
500
|
+
| `asset` | `Asset` | no | A ready asset from og.load. |
|
|
501
|
+
| `desc` | `SpawnDesc` | yes | Name, parent and transform of the root entity. |
|
|
502
|
+
|
|
503
|
+
**Returns** `Result<Entity>`: The root entity, or why it was refused (an asset still loading, a failed asset).
|
|
504
|
+
|
|
505
|
+
Binding symbol `og_world_instantiate` · publish builds: kept
|
|
506
|
+
|
|
507
|
+
```ogt
|
|
508
|
+
fn instantiate {
|
|
509
|
+
doc "Spawn a loaded scene or glTF asset into the world: a root entity from the desc, then (for a scene) every scene entity under it with its components and names, or (for a glTF) a Model on the root."
|
|
510
|
+
doc "Scene entity names must be free: a name already in use refuses the whole instantiation before anything spawns."
|
|
511
|
+
param asset Asset "A ready asset from og.load."
|
|
512
|
+
param desc SpawnDesc "Name, parent and transform of the root entity."
|
|
513
|
+
returns Result.Entity "The root entity, or why it was refused (an asset still loading, a failed asset)."
|
|
514
|
+
}
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
<sub>`api.ogt` line 356</sub>
|
|
518
|
+
|
|
519
|
+
<a id="member-World-snapshot"></a>
|
|
520
|
+
|
|
521
|
+
#### `World.snapshot`
|
|
522
|
+
|
|
523
|
+
The whole world as text, to save a game's progress in the platform store: every entity with its components and names, every resource (og.Time's clock and the og.Rng streams too), the pending events and the modules' state (physics, animation, flipbooks, tweens, tilemap and terrain edits), each type with its schema hash, deflated and base64-encoded after `og-save:1:`. Every build has it, publish included, and the same world saves to the same text on both hosts. Save it with og.platform.saveSlot (`{ slot: "slot1", text, meta: { name, chimes } }`), which spreads it over as many store keys as it needs (a key holds 64 KiB) and writes the slot's manifest last, then og.platform.loadSlot and world.restore of the answer's `text` (examples/hollowbell, a 2D platformer of 189 entities on a 96 x 48 tile map, saves to about 25 KiB; examples/kestrel-stair, a 3D world of 93 entities with skinned characters, cloths and minds, to about 78 KB; a world of a few entities to about 11 KiB, most of it the table of every registered type). Inside a system it is the world in the middle of that tick, as that system sees it: what earlier systems wrote this tick is in it, a structural change the system queued (applied when it returns) is not, and it names the system, so a world restored from it completes that tick: its next step runs the systems after this one and the engine's (physics included) with the tick's own events, then ends the tick, and the world goes on tick for tick as the one that saved did (a replay from it matches; make the snapshot the system's last write of the tick, since what it does after the call is not in the save). Between ticks (GameDesc.start, a command, a UI callback) it is the world between two ticks. Physics carries its mesh, convex-hull and height-field colliders by their geometry's handle and scale, not their triangles (og.physics.setMesh). Asset and material handles in components are saved as their numbers: load what a saved entity uses in the same order on every launch (in GameDesc.start) before restoring.
|
|
524
|
+
|
|
525
|
+
```ts
|
|
526
|
+
World.snapshot(): Result<string>
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
**Returns** `Result<string>`: The save, or why not (the world could not be read).
|
|
530
|
+
|
|
531
|
+
Binding symbol `og_world_snapshot` · publish builds: kept
|
|
532
|
+
|
|
533
|
+
```ogt
|
|
534
|
+
fn snapshot {
|
|
535
|
+
doc "The whole world as text, to save a game's progress in the platform store: every entity with its components and names, every resource (og.Time's clock and the og.Rng streams too), the pending events and the modules' state (physics, animation, flipbooks, tweens, tilemap and terrain edits), each type with its schema hash, deflated and base64-encoded after `og-save:1:`. Every build has it, publish included, and the same world saves to the same text on both hosts. Save it with og.platform.saveSlot (`{ slot: \"slot1\", text, meta: { name, chimes } }`), which spreads it over as many store keys as it needs (a key holds 64 KiB) and writes the slot's manifest last, then og.platform.loadSlot and world.restore of the answer's `text` (examples/hollowbell, a 2D platformer of 189 entities on a 96 x 48 tile map, saves to about 25 KiB; examples/kestrel-stair, a 3D world of 93 entities with skinned characters, cloths and minds, to about 78 KB; a world of a few entities to about 11 KiB, most of it the table of every registered type). Inside a system it is the world in the middle of that tick, as that system sees it: what earlier systems wrote this tick is in it, a structural change the system queued (applied when it returns) is not, and it names the system, so a world restored from it completes that tick: its next step runs the systems after this one and the engine's (physics included) with the tick's own events, then ends the tick, and the world goes on tick for tick as the one that saved did (a replay from it matches; make the snapshot the system's last write of the tick, since what it does after the call is not in the save). Between ticks (GameDesc.start, a command, a UI callback) it is the world between two ticks. Physics carries its mesh, convex-hull and height-field colliders by their geometry's handle and scale, not their triangles (og.physics.setMesh). Asset and material handles in components are saved as their numbers: load what a saved entity uses in the same order on every launch (in GameDesc.start) before restoring."
|
|
536
|
+
returns Result.String "The save, or why not (the world could not be read)."
|
|
537
|
+
}
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
<sub>`api.ogt` line 364</sub>
|
|
541
|
+
|
|
542
|
+
<a id="member-World-restore"></a>
|
|
543
|
+
|
|
544
|
+
#### `World.restore`
|
|
545
|
+
|
|
546
|
+
Replace the world with a save that world.snapshot wrote: entities, components, names, resources, events and the modules' state, so the restored world hashes as the saved one did, on either host. The session stays: input (og.Input, og.Pointers, og.Gamepad), the player's bus volumes (og.Audio), the UI's focus and hover, and what lives outside the world (the platform's calls and clock, the language, the loaded assets, the command channel's scheduled steps, which keep their remaining delays though og.Time takes the saved tick). Called in a system or a command it applies when the tick ends, after the last system; elsewhere (GameDesc.start, between ticks) at once. A save a system took mid-tick restores to that moment of its tick (og.Time reads its tick): the next step completes it (the systems after the saver, then the engine's), so the ticks after it are the saved run's. The meshes and height fields its colliders name must be loaded or registered first (a save naming one that is not is refused). A save holds only the world: progress kept in module variables is not in it, so keep it in components and resources.
|
|
547
|
+
|
|
548
|
+
```ts
|
|
549
|
+
World.restore(save: string, desc?: RestoreDesc): Result<void>
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
| Parameter | Type | Optional | Doc |
|
|
553
|
+
|---|---|---|---|
|
|
554
|
+
| `save` | `string` | no | The text world.snapshot returned. |
|
|
555
|
+
| `desc` | `RestoreDesc` | yes | Whether a type whose layout changed since the save is mapped field by field. |
|
|
556
|
+
|
|
557
|
+
**Returns** `Result<void>`: Refused, with nothing changed, for text world.snapshot did not write, a save from a newer engine, or a type whose layout changed since the save (a field added, removed or retyped, an enum's variants): the reason names the type and the fields, and the fix (`{ migrate: true }`, or keeping a saved type's fields stable between releases).
|
|
558
|
+
|
|
559
|
+
Binding symbol `og_world_restore` · publish builds: kept
|
|
560
|
+
|
|
561
|
+
```ogt
|
|
562
|
+
fn restore {
|
|
563
|
+
doc "Replace the world with a save that world.snapshot wrote: entities, components, names, resources, events and the modules' state, so the restored world hashes as the saved one did, on either host. The session stays: input (og.Input, og.Pointers, og.Gamepad), the player's bus volumes (og.Audio), the UI's focus and hover, and what lives outside the world (the platform's calls and clock, the language, the loaded assets, the command channel's scheduled steps, which keep their remaining delays though og.Time takes the saved tick). Called in a system or a command it applies when the tick ends, after the last system; elsewhere (GameDesc.start, between ticks) at once. A save a system took mid-tick restores to that moment of its tick (og.Time reads its tick): the next step completes it (the systems after the saver, then the engine's), so the ticks after it are the saved run's. The meshes and height fields its colliders name must be loaded or registered first (a save naming one that is not is refused). A save holds only the world: progress kept in module variables is not in it, so keep it in components and resources."
|
|
564
|
+
param save String "The text world.snapshot returned."
|
|
565
|
+
param desc RestoreDesc "Whether a type whose layout changed since the save is mapped field by field."
|
|
566
|
+
returns Result.Void "Refused, with nothing changed, for text world.snapshot did not write, a save from a newer engine, or a type whose layout changed since the save (a field added, removed or retyped, an enum's variants): the reason names the type and the fields, and the fix (`{ migrate: true }`, or keeping a saved type's fields stable between releases)."
|
|
567
|
+
}
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
<sub>`api.ogt` line 369</sub>
|
|
571
|
+
|
|
572
|
+
<a id="type-Query"></a>
|
|
573
|
+
|
|
574
|
+
### `Query` (interface)
|
|
575
|
+
|
|
576
|
+
A set of matched archetypes. Iterate archetypes, never entities one by one.
|
|
577
|
+
|
|
578
|
+
```ogt
|
|
579
|
+
interface Query {
|
|
580
|
+
doc "A set of matched archetypes. Iterate archetypes, never entities one by one."
|
|
581
|
+
# members follow, each quoted below
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
<sub>`api.ogt` line 377</sub>
|
|
585
|
+
|
|
586
|
+
<a id="member-Query-archetypes"></a>
|
|
587
|
+
|
|
588
|
+
#### `Query.archetypes`
|
|
589
|
+
|
|
590
|
+
The matched archetypes this tick.
|
|
591
|
+
|
|
592
|
+
```ts
|
|
593
|
+
Query.archetypes(): readonly ArchetypeView[]
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
**Returns** `readonly ArchetypeView[]`.
|
|
597
|
+
|
|
598
|
+
Binding symbol `og_query_archetypes` · publish builds: kept
|
|
599
|
+
|
|
600
|
+
```ogt
|
|
601
|
+
fn archetypes {
|
|
602
|
+
doc "The matched archetypes this tick."
|
|
603
|
+
returns List.ArchetypeView
|
|
604
|
+
}
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
<sub>`api.ogt` line 379</sub>
|
|
608
|
+
|
|
609
|
+
<a id="member-Query-count"></a>
|
|
610
|
+
|
|
611
|
+
#### `Query.count`
|
|
612
|
+
|
|
613
|
+
The number of matched entities.
|
|
614
|
+
|
|
615
|
+
```ts
|
|
616
|
+
Query.count(): number
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
**Returns** `number`.
|
|
620
|
+
|
|
621
|
+
Binding symbol `og_query_count` · publish builds: kept
|
|
622
|
+
|
|
623
|
+
```ogt
|
|
624
|
+
fn count {
|
|
625
|
+
doc "The number of matched entities."
|
|
626
|
+
returns u32
|
|
627
|
+
}
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
<sub>`api.ogt` line 383</sub>
|
|
631
|
+
|
|
632
|
+
<a id="type-ArchetypeView"></a>
|
|
633
|
+
|
|
634
|
+
### `ArchetypeView` (interface)
|
|
635
|
+
|
|
636
|
+
One archetype's columns for this tick. Views are invalidated by structural changes; using a stale view throws with the tick and the system it belonged to.
|
|
637
|
+
|
|
638
|
+
```ogt
|
|
639
|
+
interface ArchetypeView {
|
|
640
|
+
doc "One archetype's columns for this tick. Views are invalidated by structural changes; using a stale view throws with the tick and the system it belonged to."
|
|
641
|
+
# members follow, each quoted below
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
<sub>`api.ogt` line 389</sub>
|
|
645
|
+
|
|
646
|
+
<a id="member-ArchetypeView-count"></a>
|
|
647
|
+
|
|
648
|
+
#### `ArchetypeView.count` (property)
|
|
649
|
+
|
|
650
|
+
The number of entities in the archetype.
|
|
651
|
+
|
|
652
|
+
```ts
|
|
653
|
+
readonly count: number
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
Binding symbol `og_archetype_view_get_count` · publish builds: kept
|
|
657
|
+
|
|
658
|
+
```ogt
|
|
659
|
+
prop count u32 "The number of entities in the archetype."
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
<sub>`api.ogt` line 391</sub>
|
|
663
|
+
|
|
664
|
+
<a id="member-ArchetypeView-tick"></a>
|
|
665
|
+
|
|
666
|
+
#### `ArchetypeView.tick` (property)
|
|
667
|
+
|
|
668
|
+
The tick this view belongs to.
|
|
669
|
+
|
|
670
|
+
```ts
|
|
671
|
+
readonly tick: number
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
Binding symbol `og_archetype_view_get_tick` · publish builds: kept
|
|
675
|
+
|
|
676
|
+
```ogt
|
|
677
|
+
prop tick u32 "The tick this view belongs to."
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
<sub>`api.ogt` line 392</sub>
|
|
681
|
+
|
|
682
|
+
<a id="member-ArchetypeView-entities"></a>
|
|
683
|
+
|
|
684
|
+
#### `ArchetypeView.entities` (property)
|
|
685
|
+
|
|
686
|
+
The entities as (index, generation) pairs: entity i is at 2i and 2i + 1.
|
|
687
|
+
|
|
688
|
+
```ts
|
|
689
|
+
readonly entities: Uint32Array
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
Binding symbol `og_archetype_view_get_entities` · publish builds: kept
|
|
693
|
+
|
|
694
|
+
```ogt
|
|
695
|
+
prop entities Uint32Array "The entities as (index, generation) pairs: entity i is at 2i and 2i + 1."
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
<sub>`api.ogt` line 393</sub>
|
|
699
|
+
|
|
700
|
+
<a id="member-ArchetypeView-entity"></a>
|
|
701
|
+
|
|
702
|
+
#### `ArchetypeView.entity`
|
|
703
|
+
|
|
704
|
+
The handle of entity i.
|
|
705
|
+
|
|
706
|
+
```ts
|
|
707
|
+
ArchetypeView.entity(index: number): Entity
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
| Parameter | Type | Optional | Doc |
|
|
711
|
+
|---|---|---|---|
|
|
712
|
+
| `index` | `number` | no | The row, from 0 to count - 1. |
|
|
713
|
+
|
|
714
|
+
**Returns** `Entity`.
|
|
715
|
+
|
|
716
|
+
Binding symbol `og_archetype_view_entity` · publish builds: kept
|
|
717
|
+
|
|
718
|
+
```ogt
|
|
719
|
+
fn entity {
|
|
720
|
+
doc "The handle of entity i."
|
|
721
|
+
param index u32 "The row, from 0 to count - 1."
|
|
722
|
+
returns Entity
|
|
723
|
+
}
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
<sub>`api.ogt` line 394</sub>
|
|
727
|
+
|
|
728
|
+
<a id="member-ArchetypeView-has"></a>
|
|
729
|
+
|
|
730
|
+
#### `ArchetypeView.has`
|
|
731
|
+
|
|
732
|
+
Whether the archetype carries a component.
|
|
733
|
+
|
|
734
|
+
```ts
|
|
735
|
+
ArchetypeView.has<C extends AnyComponent>(component: C): boolean
|
|
736
|
+
```
|
|
737
|
+
|
|
738
|
+
| Parameter | Type | Optional | Doc |
|
|
739
|
+
|---|---|---|---|
|
|
740
|
+
| `component` | `C` | no | The component token. |
|
|
741
|
+
|
|
742
|
+
**Returns** `boolean`.
|
|
743
|
+
|
|
744
|
+
Binding symbol `og_archetype_view_has` · publish builds: kept
|
|
745
|
+
|
|
746
|
+
```ogt
|
|
747
|
+
fn has {
|
|
748
|
+
doc "Whether the archetype carries a component."
|
|
749
|
+
generic C AnyComponent
|
|
750
|
+
param component C "The component token."
|
|
751
|
+
returns bool
|
|
752
|
+
}
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
<sub>`api.ogt` line 399</sub>
|
|
756
|
+
|
|
757
|
+
<a id="member-ArchetypeView-column"></a>
|
|
758
|
+
|
|
759
|
+
#### `ArchetypeView.column`
|
|
760
|
+
|
|
761
|
+
The typed views of a component's fields: one typed array per field, `count * stride` long.
|
|
762
|
+
|
|
763
|
+
Writing requires the component among the system's writes; reading among its reads or writes.
|
|
764
|
+
|
|
765
|
+
```ts
|
|
766
|
+
ArchetypeView.column<C extends AnyComponent>(component: C): View<C>
|
|
767
|
+
```
|
|
768
|
+
|
|
769
|
+
| Parameter | Type | Optional | Doc |
|
|
770
|
+
|---|---|---|---|
|
|
771
|
+
| `component` | `C` | no | The component token. |
|
|
772
|
+
|
|
773
|
+
**Returns** `View<C>`.
|
|
774
|
+
|
|
775
|
+
Binding symbol `og_archetype_view_column` · publish builds: kept
|
|
776
|
+
|
|
777
|
+
```ogt
|
|
778
|
+
fn column {
|
|
779
|
+
doc "The typed views of a component's fields: one typed array per field, `count * stride` long."
|
|
780
|
+
doc "Writing requires the component among the system's writes; reading among its reads or writes."
|
|
781
|
+
generic C AnyComponent
|
|
782
|
+
param component C "The component token."
|
|
783
|
+
returns View.C
|
|
784
|
+
}
|
|
785
|
+
```
|
|
786
|
+
|
|
787
|
+
<sub>`api.ogt` line 405</sub>
|
|
788
|
+
|
|
789
|
+
## Types
|
|
790
|
+
|
|
791
|
+
<a id="type-Entity"></a>
|
|
792
|
+
|
|
793
|
+
### `Entity` (handle)
|
|
794
|
+
|
|
795
|
+
An entity: an index and a generation. The value is index + generation * 2^32, with the generation below 2^21, so it stays an exact JavaScript number.
|
|
796
|
+
|
|
797
|
+
Generations start at 1, so 0 is never a live entity.
|
|
798
|
+
|
|
799
|
+
A generational handle: a number the engine hands out. A dead handle is an error value, never a crash.
|
|
800
|
+
|
|
801
|
+
```ogt
|
|
802
|
+
handle Entity {
|
|
803
|
+
doc "An entity: an index and a generation. The value is index + generation * 2^32, with the generation below 2^21, so it stays an exact JavaScript number."
|
|
804
|
+
doc "Generations start at 1, so 0 is never a live entity."
|
|
805
|
+
}
|
|
806
|
+
```
|
|
807
|
+
|
|
808
|
+
<sub>`api.ogt` line 209</sub>
|
|
809
|
+
|
|
810
|
+
<a id="type-SpawnDesc"></a>
|
|
811
|
+
|
|
812
|
+
### `SpawnDesc` (desc struct)
|
|
813
|
+
|
|
814
|
+
How to spawn an entity. `{}` spawns an unnamed entity at the origin with a Transform.
|
|
815
|
+
|
|
816
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
817
|
+
|
|
818
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
819
|
+
|---|---|---|---|---|---|---|
|
|
820
|
+
| `name` | `string` | `""` | — | — | — | A unique name; the probe and the command channel address the entity by it. Empty leaves it unnamed. |
|
|
821
|
+
| `parent` | `Entity \| null` | `null` | — | — | — | The parent entity; the new entity's Transform is then relative to it. |
|
|
822
|
+
| `position` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | The initial Transform.position. |
|
|
823
|
+
| `quaternion` | `Quaternion` | `{ x: 0, y: 0, z: 0, w: 1 }` | — | — | — | The initial Transform.quaternion. |
|
|
824
|
+
| `scale` | `Vector3` | `{ x: 1, y: 1, z: 1 }` | — | — | — | The initial Transform.scale. |
|
|
825
|
+
| `bare` | `boolean` | `false` | — | — | — | Spawn without a Transform: a pure data entity. |
|
|
826
|
+
|
|
827
|
+
```ogt
|
|
828
|
+
struct SpawnDesc {
|
|
829
|
+
doc "How to spawn an entity. `{}` spawns an unnamed entity at the origin with a Transform."
|
|
830
|
+
desc true
|
|
831
|
+
field name String "A unique name; the probe and the command channel address the entity by it. Empty leaves it unnamed."
|
|
832
|
+
field parent Option.Entity "The parent entity; the new entity's Transform is then relative to it."
|
|
833
|
+
field position Vector3 "The initial Transform.position." {
|
|
834
|
+
unit m
|
|
835
|
+
}
|
|
836
|
+
field quaternion Quaternion "The initial Transform.quaternion."
|
|
837
|
+
field scale Vector3 "The initial Transform.scale." {
|
|
838
|
+
default 1 1 1
|
|
839
|
+
}
|
|
840
|
+
field bare bool "Spawn without a Transform: a pure data entity."
|
|
841
|
+
}
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
<sub>`api.ogt` line 221</sub>
|
|
845
|
+
|
|
846
|
+
<a id="type-RestoreDesc"></a>
|
|
847
|
+
|
|
848
|
+
### `RestoreDesc` (desc struct)
|
|
849
|
+
|
|
850
|
+
How world.restore takes a save.
|
|
851
|
+
|
|
852
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
853
|
+
|
|
854
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
855
|
+
|---|---|---|---|---|---|---|
|
|
856
|
+
| `migrate` | `boolean` | `false` | — | — | — | Map a type whose layout changed since the save field by field, by name, as a hot reload does: a field added since takes its default, a removed one is dropped, an enum value is mapped by its variant's name, a field of another type starts at its default, and a type this build no longer registers is dropped. Off, such a save is refused naming the type and its fields. |
|
|
857
|
+
|
|
858
|
+
```ogt
|
|
859
|
+
struct RestoreDesc {
|
|
860
|
+
doc "How world.restore takes a save."
|
|
861
|
+
desc true
|
|
862
|
+
field migrate bool "Map a type whose layout changed since the save field by field, by name, as a hot reload does: a field added since takes its default, a removed one is dropped, an enum value is mapped by its variant's name, a field of another type starts at its default, and a type this build no longer registers is dropped. Off, such a save is refused naming the type and its fields."
|
|
863
|
+
}
|
|
864
|
+
```
|
|
865
|
+
|
|
866
|
+
<sub>`api.ogt` line 236</sub>
|
|
867
|
+
|
|
868
|
+
<a id="type-QueryDesc"></a>
|
|
869
|
+
|
|
870
|
+
### `QueryDesc` (desc struct)
|
|
871
|
+
|
|
872
|
+
Which entities a query matches.
|
|
873
|
+
|
|
874
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
875
|
+
|
|
876
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
877
|
+
|---|---|---|---|---|---|---|
|
|
878
|
+
| `with` | `readonly AnyComponent[]` | `[]` | — | — | — | Components an entity must have. |
|
|
879
|
+
| `without` | `readonly AnyComponent[]` | `[]` | — | — | — | Components an entity must not have. |
|
|
880
|
+
|
|
881
|
+
```ogt
|
|
882
|
+
struct QueryDesc {
|
|
883
|
+
doc "Which entities a query matches."
|
|
884
|
+
desc true
|
|
885
|
+
field with List.AnyComponent "Components an entity must have."
|
|
886
|
+
field without List.AnyComponent "Components an entity must not have."
|
|
887
|
+
}
|
|
888
|
+
```
|
|
889
|
+
|
|
890
|
+
<sub>`api.ogt` line 242</sub>
|
|
891
|
+
|
|
892
|
+
## Column kinds
|
|
893
|
+
|
|
894
|
+
Each is a factory, `Entity(value?, options?)`, that makes one field of a component or resource layout.
|
|
895
|
+
|
|
896
|
+
| Column | Value | Typed array | Stride | Doc |
|
|
897
|
+
|---|---|---|---|---|
|
|
898
|
+
| <a id="column-Entity"></a>`Entity` | `Entity` | `Uint32Array` | 2 | An Entity field: (index, generation) pairs. |
|
|
899
|
+
|
|
900
|
+
```ogt
|
|
901
|
+
column Entity {
|
|
902
|
+
doc "An Entity field: (index, generation) pairs."
|
|
903
|
+
array Uint32Array
|
|
904
|
+
stride 2
|
|
905
|
+
value Entity
|
|
906
|
+
}
|
|
907
|
+
```
|
|
908
|
+
|
|
909
|
+
<sub>`api.ogt` line 214</sub>
|