@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.
Files changed (159) hide show
  1. package/bin/og.mjs +25 -0
  2. package/dist/web/origin-engine.d.ts +1233 -0
  3. package/dist/web/origin-engine.js +8628 -0
  4. package/dist/web/origin-engine_bg.wasm +0 -0
  5. package/dist/web/origin-engine_bg.wasm.d.ts +366 -0
  6. package/dist/web-publish/origin-engine-lanes.js +8509 -0
  7. package/dist/web-publish/origin-engine-lanes_bg.wasm +0 -0
  8. package/dist/web-publish/origin-engine.d.ts +1176 -0
  9. package/dist/web-publish/origin-engine.js +8313 -0
  10. package/dist/web-publish/origin-engine_bg.wasm +0 -0
  11. package/dist/web-publish/origin-engine_bg.wasm.d.ts +347 -0
  12. package/dist/web-publish/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.no-bundler.js +77 -0
  13. package/dist/web-publish-2d/origin-engine-lanes.js +8509 -0
  14. package/dist/web-publish-2d/origin-engine-lanes_bg.wasm +0 -0
  15. package/dist/web-publish-2d/origin-engine.d.ts +1176 -0
  16. package/dist/web-publish-2d/origin-engine.js +8313 -0
  17. package/dist/web-publish-2d/origin-engine_bg.wasm +0 -0
  18. package/dist/web-publish-2d/origin-engine_bg.wasm.d.ts +347 -0
  19. package/dist/web-publish-2d/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.no-bundler.js +77 -0
  20. package/knowledge/README.md +31 -0
  21. package/knowledge/knowledge.json +13 -0
  22. package/knowledge/looks/catalogue.json +1871 -0
  23. package/knowledge/package.json +33 -0
  24. package/knowledge/rules/platform.json +329 -0
  25. package/knowledge/scaffold/README.md +27 -0
  26. package/knowledge/scaffold/distribution.json +48 -0
  27. package/knowledge/scaffold/origin-engine.json +19 -0
  28. package/knowledge/scaffold/template/.origin/setup +14 -0
  29. package/knowledge/scaffold/template/LICENSES.md +23 -0
  30. package/knowledge/scaffold/template/README.md +37 -0
  31. package/knowledge/scaffold/template/assets/ai/guard.ogt +48 -0
  32. package/knowledge/scaffold/template/assets/audio/click.ogt +9 -0
  33. package/knowledge/scaffold/template/assets/fonts/NotoSansSC-Regular-subset.ttf.ogt +12 -0
  34. package/knowledge/scaffold/template/assets/fonts/OFL.txt +93 -0
  35. package/knowledge/scaffold/template/assets/looks/origin-game.ogt +12 -0
  36. package/knowledge/scaffold/template/assets/nav/yard.ogt +27 -0
  37. package/knowledge/scaffold/template/assets/scenes/main.ogt +34 -0
  38. package/knowledge/scaffold/template/assets/strings/en.ogt +14 -0
  39. package/knowledge/scaffold/template/assets/textures/stone_n.png.ogt +7 -0
  40. package/knowledge/scaffold/template/gitattributes +22 -0
  41. package/knowledge/scaffold/template/gitignore +8 -0
  42. package/knowledge/scaffold/template/package.json +18 -0
  43. package/knowledge/scaffold/template/project.ogt +25 -0
  44. package/knowledge/scaffold/template/src/main.ts +246 -0
  45. package/knowledge/scaffold/template/tests/guard.og.ts +67 -0
  46. package/knowledge/scaffold/template/tests/smoke.og.ts +43 -0
  47. package/knowledge/scaffold/template/tsconfig.json +17 -0
  48. package/knowledge/scripts/lib.ts +207 -0
  49. package/knowledge/scripts/mount.ts +210 -0
  50. package/knowledge/scripts/pack.ts +25 -0
  51. package/knowledge/scripts/scaffold.ts +72 -0
  52. package/knowledge/scripts/validate.ts +749 -0
  53. package/knowledge/skills/og-ai/SKILL.md +386 -0
  54. package/knowledge/skills/og-audio/SKILL.md +191 -0
  55. package/knowledge/skills/og-build/SKILL.md +330 -0
  56. package/knowledge/skills/og-core/SKILL.md +285 -0
  57. package/knowledge/skills/og-feel/SKILL.md +385 -0
  58. package/knowledge/skills/og-game/SKILL.md +1479 -0
  59. package/knowledge/skills/og-i18n/SKILL.md +220 -0
  60. package/knowledge/skills/og-platform-sdk/SKILL.md +199 -0
  61. package/knowledge/skills/og-taste/SKILL.md +537 -0
  62. package/knowledge/skills/og-ui/SKILL.md +444 -0
  63. package/knowledge/wiki/ai.md +627 -0
  64. package/knowledge/wiki/anim.md +1187 -0
  65. package/knowledge/wiki/atmosphere.md +636 -0
  66. package/knowledge/wiki/audio.md +732 -0
  67. package/knowledge/wiki/camera.md +711 -0
  68. package/knowledge/wiki/commands.md +357 -0
  69. package/knowledge/wiki/game.md +220 -0
  70. package/knowledge/wiki/i18n.md +213 -0
  71. package/knowledge/wiki/index.md +1027 -0
  72. package/knowledge/wiki/input.md +1714 -0
  73. package/knowledge/wiki/load.md +1280 -0
  74. package/knowledge/wiki/math.md +166 -0
  75. package/knowledge/wiki/nav.md +1154 -0
  76. package/knowledge/wiki/physics.md +3142 -0
  77. package/knowledge/wiki/platform.md +857 -0
  78. package/knowledge/wiki/probe.md +1692 -0
  79. package/knowledge/wiki/reflect.md +285 -0
  80. package/knowledge/wiki/render.md +3511 -0
  81. package/knowledge/wiki/rng.md +393 -0
  82. package/knowledge/wiki/stream.md +376 -0
  83. package/knowledge/wiki/system.md +197 -0
  84. package/knowledge/wiki/systems.md +43 -0
  85. package/knowledge/wiki/terrain.md +727 -0
  86. package/knowledge/wiki/tilemap.md +422 -0
  87. package/knowledge/wiki/time.md +150 -0
  88. package/knowledge/wiki/transform.md +230 -0
  89. package/knowledge/wiki/tween.md +580 -0
  90. package/knowledge/wiki/ui.md +8000 -0
  91. package/knowledge/wiki/world.md +909 -0
  92. package/package.json +68 -4
  93. package/schema/api.schema.json +29675 -0
  94. package/shell/README.md +22 -0
  95. package/shell/brand/README.md +23 -0
  96. package/shell/brand/icon-192.png +0 -0
  97. package/shell/brand/icon-512.png +0 -0
  98. package/shell/brand/mark-on-paper.svg +6 -0
  99. package/shell/brand/origin-mark.svg +5 -0
  100. package/shell/brand/origin-motion.css +251 -0
  101. package/shell/brand/tokens.css +20 -0
  102. package/shell/brand.ts +132 -0
  103. package/shell/page.ts +715 -0
  104. package/shell/platform.ts +203 -0
  105. package/shell/player.ts +238 -0
  106. package/shell/shell.css +185 -0
  107. package/shell/sw.ts +177 -0
  108. package/shell/transport.ts +515 -0
  109. package/shell/wire.ts +369 -0
  110. package/src/e6.ts +69 -0
  111. package/src/env.d.ts +100 -0
  112. package/src/generated/abi.ts +980 -0
  113. package/src/index.ts +193 -0
  114. package/src/node/audio.ts +86 -0
  115. package/src/node/build.ts +109 -0
  116. package/src/node/device.ts +981 -0
  117. package/src/node/doctor.ts +60 -0
  118. package/src/node/index.ts +102 -0
  119. package/src/node/platform.ts +24 -0
  120. package/src/node/playtest-run.ts +249 -0
  121. package/src/node/png.ts +130 -0
  122. package/src/node/polish.ts +976 -0
  123. package/src/node/run.ts +373 -0
  124. package/src/node/web-build.ts +808 -0
  125. package/src/p2.ts +35 -0
  126. package/src/platform-local.ts +211 -0
  127. package/src/playtest.ts +131 -0
  128. package/src/runtime.ts +1509 -0
  129. package/src/systems/cameras.ts +247 -0
  130. package/src/ui-kit/bind.ts +141 -0
  131. package/src/ui-kit/huds.ts +303 -0
  132. package/src/ui-kit/index.ts +36 -0
  133. package/src/ui-kit/menus.ts +187 -0
  134. package/src/ui-kit/settings.ts +131 -0
  135. package/src/ui-kit/store.ts +222 -0
  136. package/src/ui-kit/story.ts +89 -0
  137. package/src/ui-kit/util.ts +106 -0
  138. package/src/web/a11y.ts +429 -0
  139. package/src/web/audio-worklet.ts +193 -0
  140. package/src/web/audio.ts +307 -0
  141. package/src/web/basis.ts +239 -0
  142. package/src/web/gamepad.ts +123 -0
  143. package/src/web/host.ts +166 -0
  144. package/src/web/input.ts +237 -0
  145. package/src/web/lanes.ts +21 -0
  146. package/src/web/play.ts +20 -0
  147. package/src/web/rpc-ring.ts +110 -0
  148. package/src/web/settle.ts +122 -0
  149. package/src/web/shell.ts +643 -0
  150. package/src/web/text-input.ts +248 -0
  151. package/src/web/worker.ts +1002 -0
  152. package/types/bindings.json +13654 -0
  153. package/types/index.d.ts +20090 -0
  154. package/vendor/basis/LICENSE +201 -0
  155. package/vendor/basis/NOTICE +15 -0
  156. package/vendor/basis/README.md +18 -0
  157. package/vendor/basis/basis_transcoder.js +19 -0
  158. package/vendor/basis/basis_transcoder.wasm +0 -0
  159. package/README.md +0 -3
@@ -0,0 +1,357 @@
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 `commands` module
4
+
5
+ The command channel: actions scheduled on simulation time, from `og run --commands "t:action[:args];..."` or the probe's commands().
6
+
7
+ Core actions ship with the engine; a module or a game registers more. Unknown actions warn and continue. Not in publish builds.
8
+
9
+ Outputs are relative to the output directory: an absolute path, a `..` component or a name starting with `.` (kept for the harness, such as a playtest's kept store) is refused. A file an earlier step of the script wrote is never overwritten: the later step's is written as `<stem>-2.<ext>` with a warning naming both steps.
10
+
11
+ - **TypeScript**: functions are the namespace `og.commands`; components, resources and events are tokens on `og`.
12
+ - **Publish builds**: dropped (members may override).
13
+ - **Skill**: `og-build`, which teaches the module (how much of it to use, and how to prove it).
14
+ - **Index**: [every module and name](index.md).
15
+
16
+ ```ogt
17
+ module commands {
18
+ # declarations follow, each quoted below
19
+ ```
20
+
21
+ <sub>`api.ogt` line 10355</sub>
22
+
23
+ ## Contents
24
+
25
+ | Name | Kind | Summary |
26
+ |---|---|---|
27
+ | [`CoreAction`](#type-CoreAction) | enum | The actions the engine ships. Arguments follow the action, separated by `:`. |
28
+ | [`CommandHandler`](#type-CommandHandler) | callback | A registered action. It runs at the start of the tick it was scheduled for. |
29
+ | [`CommandDesc`](#type-CommandDesc) | desc struct | How a registered action describes itself in `og run --help` and the wiki. |
30
+ | [`CommandStep`](#type-CommandStep) | struct | One parsed step of a command script. |
31
+ | [`CommandInfo`](#type-CommandInfo) | struct | One action as help lists it. |
32
+ | [`CommandsReport`](#type-CommandsReport) | struct | What scheduling a script did. |
33
+ | [`og.commands.register`](#fn-register) | function | Register an action into the command channel. GameDesc.commands does this for a game's own actions. |
34
+ | [`og.commands.parse`](#fn-parse) | function | Parse a script without scheduling it. |
35
+ | [`og.commands.help`](#fn-help) | function | Every action the channel knows: core actions in CoreAction order, then registered ones by name. |
36
+ | [`og.commands.schedule`](#fn-schedule) | function | Schedule a script on simulation time, from the current tick. |
37
+
38
+ ## Functions
39
+
40
+ <a id="fn-register"></a>
41
+
42
+ ### `og.commands.register`
43
+
44
+ Register an action into the command channel. GameDesc.commands does this for a game's own actions.
45
+
46
+ ```ts
47
+ og.commands.register(name: string, handler: CommandHandler, desc?: CommandDesc): Result<void>
48
+ ```
49
+
50
+ | Parameter | Type | Optional | Doc |
51
+ |---|---|---|---|
52
+ | `name` | `string` | no | The action name, snake_case, such as `spawn_wave`. |
53
+ | `handler` | `CommandHandler` | no | What it does. |
54
+ | `desc` | `CommandDesc` | yes | Its usage line and doc. |
55
+
56
+ **Returns** `Result<void>`: Refused for a name a core action or another registration already uses.
57
+
58
+ Binding symbol `og_commands_register` · publish builds: dropped
59
+
60
+ ```ogt
61
+ fn register {
62
+ doc "Register an action into the command channel. GameDesc.commands does this for a game's own actions."
63
+ param name String "The action name, snake_case, such as `spawn_wave`."
64
+ param handler CommandHandler "What it does."
65
+ param desc CommandDesc "Its usage line and doc."
66
+ returns Result.Void "Refused for a name a core action or another registration already uses."
67
+ }
68
+ ```
69
+
70
+ <sub>`api.ogt` line 10431</sub>
71
+
72
+ <a id="fn-parse"></a>
73
+
74
+ ### `og.commands.parse`
75
+
76
+ Parse a script without scheduling it.
77
+
78
+ ```ts
79
+ og.commands.parse(script: string): Result<readonly CommandStep[]>
80
+ ```
81
+
82
+ | Parameter | Type | Optional | Doc |
83
+ |---|---|---|---|
84
+ | `script` | `string` | no | `t:action[:args];...` with t in simulation seconds. |
85
+
86
+ **Returns** `Result<readonly CommandStep[]>`: The steps, or the first malformed step.
87
+
88
+ Binding symbol `og_commands_parse` · publish builds: dropped
89
+
90
+ ```ogt
91
+ fn parse {
92
+ doc "Parse a script without scheduling it."
93
+ param script String "`t:action[:args];...` with t in simulation seconds."
94
+ returns Result.List.CommandStep "The steps, or the first malformed step."
95
+ }
96
+ ```
97
+
98
+ <sub>`api.ogt` line 10439</sub>
99
+
100
+ <a id="fn-help"></a>
101
+
102
+ ### `og.commands.help`
103
+
104
+ Every action the channel knows: core actions in CoreAction order, then registered ones by name.
105
+
106
+ ```ts
107
+ og.commands.help(world: World): readonly CommandInfo[]
108
+ ```
109
+
110
+ | Parameter | Type | Optional | Doc |
111
+ |---|---|---|---|
112
+ | `world` | `World` | no | The world whose channel is asked. |
113
+
114
+ **Returns** `readonly CommandInfo[]`.
115
+
116
+ Binding symbol `og_commands_help` · publish builds: dropped
117
+
118
+ ```ogt
119
+ fn help {
120
+ doc "Every action the channel knows: core actions in CoreAction order, then registered ones by name."
121
+ param world World "The world whose channel is asked."
122
+ returns List.CommandInfo
123
+ }
124
+ ```
125
+
126
+ <sub>`api.ogt` line 10445</sub>
127
+
128
+ <a id="fn-schedule"></a>
129
+
130
+ ### `og.commands.schedule`
131
+
132
+ Schedule a script on simulation time, from the current tick.
133
+
134
+ ```ts
135
+ og.commands.schedule(world: World, script: string): Result<CommandsReport>
136
+ ```
137
+
138
+ | Parameter | Type | Optional | Doc |
139
+ |---|---|---|---|
140
+ | `world` | `World` | no | The world. |
141
+ | `script` | `string` | no | `t:action[:args];...` with t in simulation seconds. |
142
+
143
+ **Returns** `Result<CommandsReport>`: The report, or the first malformed step.
144
+
145
+ Binding symbol `og_commands_schedule` · publish builds: dropped
146
+
147
+ ```ogt
148
+ fn schedule {
149
+ doc "Schedule a script on simulation time, from the current tick."
150
+ param world World "The world."
151
+ param script String "`t:action[:args];...` with t in simulation seconds."
152
+ returns Result.CommandsReport "The report, or the first malformed step."
153
+ }
154
+ ```
155
+
156
+ <sub>`api.ogt` line 10451</sub>
157
+
158
+ ## Types
159
+
160
+ <a id="type-CoreAction"></a>
161
+
162
+ ### `CoreAction` (enum)
163
+
164
+ The actions the engine ships. Arguments follow the action, separated by `:`.
165
+
166
+ A string: one of the variants below. The zero value is `"screenshot"`.
167
+
168
+ | Variant | Doc |
169
+ |---|---|
170
+ | `"screenshot"` | `screenshot[:path][:full\|:N]`: capture the next frame. Without a renderer it writes nothing and logs, not as a warning, that the frame is unchecked. |
171
+ | `"listen"` | `listen[:path][:seconds]`: write the last seconds of rendered audio as a WAV. |
172
+ | `"touch_move_to"` | `touch_move_to:<ui id>`: move the pointer to a UI element. |
173
+ | `"touch_move"` | `touch_move:x,y`: move the pointer to CSS pixel coordinates. |
174
+ | `"touch_start"` | `touch_start`: press the pointer where it is. |
175
+ | `"touch_end"` | `touch_end`: release the pointer. |
176
+ | `"scroll"` | `scroll:dx,dy`: scroll at the pointer. |
177
+ | `"touch"` | `touch:<id>:<down\|move\|up>:<x,y \| ui id>`: a further touch (pointer 1 to 4) held while the pointer is busy elsewhere. |
178
+ | `"gamepad"` | `gamepad:<a+b+...\|->[@pad][:lx,ly[,rx,ry]][:lt,rt]`: set a pad's whole state (pad 0 unless `@1` to `@3` follows the buttons); `gamepad:off` disconnects it. |
179
+ | `"key_down"` | `key_down:[Mod+]<Key>`: hold a key by its code, with the modifiers named before it (`Shift+ArrowLeft`, `Meta+ArrowLeft` for Command, apart from Ctrl). |
180
+ | `"key_up"` | `key_up:[Mod+]<Key>`: release a key, then the modifiers named before it. |
181
+ | `"type"` | `type:<text>`: type text, two ticks per character: its key press and the character as typed text (input.TextInput); a character no key types is typed text alone. The text runs to the `;` exactly, a trailing space included; after it a text field takes typed text only, so a bare key_down types nothing. |
182
+ | `"compose"` | `compose:<text>`: an input method's composition so far (input.TextInput composing); a focused text field shows it underlined at the caret, `compose:` with nothing ends it. |
183
+ | `"commit"` | `commit:<text>`: an input method commits text; a focused text field inserts it and the composition ends. |
184
+ | `"move_to_text"` | `move_to_text:[=]text[@N]`: move the pointer to the UI element showing the text (exactly with `=`, the Nth with `@N`). |
185
+ | `"teleport"` | `teleport:<entity>:x,y,z`: set an entity's position. |
186
+ | `"frame_entity"` | `frame_entity:<entity>`: point the camera at an entity. |
187
+ | `"dump_world"` | `dump_world[:path]`: tables, systems and their matched counts. |
188
+ | `"dump_entity"` | `dump_entity:<name>[:path]`: one entity's components and transform. |
189
+ | `"dump_ui"` | `dump_ui[:path]`: the UI tree with bounds. |
190
+ | `"set"` | `set:<entity>.<component>.<field>=<value>` or `set:<Resource>.<field>=<value>`: a Tune write through the schema: a number, `true` or `false` for a bool, `x,y,z` for a vector, an enum's variant name or its index; refused outside the field's FieldOptions min/max, never clamped. |
191
+ | `"get"` | `get:<Resource>[.<field>]` or `get:<entity>[.<component>[.<field>]][:path]`: read through the schema as game code sees it (an enum as its variant's name, `"music"`; og.Time whole, with rate and the time scale; the DirectionalLight og.DayNight drives with the colour, intensity and direction it is drawn with), logged and written as JSON to `get-<tick>.json` (more unnamed ones on one tick: `get-<tick>-2.json`, ...). |
192
+ | `"seed"` | `seed:<n>`: reseed the Rng resource. |
193
+ | `"pause"` | `pause`: hold the clock; advance still steps. |
194
+ | `"resume"` | `resume`: release the clock. |
195
+ | `"advance"` | `advance:<ticks>`: take fixed steps. |
196
+ | `"quit"` | `quit`: exit. |
197
+ | `"help"` | `help`: list every action the channel knows, core and registered. |
198
+
199
+ ```ogt
200
+ enum CoreAction {
201
+ doc "The actions the engine ships. Arguments follow the action, separated by `:`."
202
+ variant screenshot "`screenshot[:path][:full|:N]`: capture the next frame. Without a renderer it writes nothing and logs, not as a warning, that the frame is unchecked."
203
+ variant listen "`listen[:path][:seconds]`: write the last seconds of rendered audio as a WAV."
204
+ variant touch_move_to "`touch_move_to:<ui id>`: move the pointer to a UI element."
205
+ variant touch_move "`touch_move:x,y`: move the pointer to CSS pixel coordinates."
206
+ variant touch_start "`touch_start`: press the pointer where it is."
207
+ variant touch_end "`touch_end`: release the pointer."
208
+ variant scroll "`scroll:dx,dy`: scroll at the pointer."
209
+ variant touch "`touch:<id>:<down|move|up>:<x,y | ui id>`: a further touch (pointer 1 to 4) held while the pointer is busy elsewhere."
210
+ variant gamepad "`gamepad:<a+b+...|->[@pad][:lx,ly[,rx,ry]][:lt,rt]`: set a pad's whole state (pad 0 unless `@1` to `@3` follows the buttons); `gamepad:off` disconnects it."
211
+ variant key_down "`key_down:[Mod+]<Key>`: hold a key by its code, with the modifiers named before it (`Shift+ArrowLeft`, `Meta+ArrowLeft` for Command, apart from Ctrl)."
212
+ variant key_up "`key_up:[Mod+]<Key>`: release a key, then the modifiers named before it."
213
+ variant type "`type:<text>`: type text, two ticks per character: its key press and the character as typed text (input.TextInput); a character no key types is typed text alone. The text runs to the `;` exactly, a trailing space included; after it a text field takes typed text only, so a bare key_down types nothing."
214
+ variant compose "`compose:<text>`: an input method's composition so far (input.TextInput composing); a focused text field shows it underlined at the caret, `compose:` with nothing ends it."
215
+ variant commit "`commit:<text>`: an input method commits text; a focused text field inserts it and the composition ends."
216
+ variant move_to_text "`move_to_text:[=]text[@N]`: move the pointer to the UI element showing the text (exactly with `=`, the Nth with `@N`)."
217
+ variant teleport "`teleport:<entity>:x,y,z`: set an entity's position."
218
+ variant frame_entity "`frame_entity:<entity>`: point the camera at an entity."
219
+ variant dump_world "`dump_world[:path]`: tables, systems and their matched counts."
220
+ variant dump_entity "`dump_entity:<name>[:path]`: one entity's components and transform."
221
+ variant dump_ui "`dump_ui[:path]`: the UI tree with bounds."
222
+ variant set "`set:<entity>.<component>.<field>=<value>` or `set:<Resource>.<field>=<value>`: a Tune write through the schema: a number, `true` or `false` for a bool, `x,y,z` for a vector, an enum's variant name or its index; refused outside the field's FieldOptions min/max, never clamped."
223
+ variant get "`get:<Resource>[.<field>]` or `get:<entity>[.<component>[.<field>]][:path]`: read through the schema as game code sees it (an enum as its variant's name, `\"music\"`; og.Time whole, with rate and the time scale; the DirectionalLight og.DayNight drives with the colour, intensity and direction it is drawn with), logged and written as JSON to `get-<tick>.json` (more unnamed ones on one tick: `get-<tick>-2.json`, ...)."
224
+ variant seed "`seed:<n>`: reseed the Rng resource."
225
+ variant pause "`pause`: hold the clock; advance still steps."
226
+ variant resume "`resume`: release the clock."
227
+ variant advance "`advance:<ticks>`: take fixed steps."
228
+ variant quit "`quit`: exit."
229
+ variant help "`help`: list every action the channel knows, core and registered."
230
+ }
231
+ ```
232
+
233
+ <sub>`api.ogt` line 10362</sub>
234
+
235
+ <a id="type-CommandHandler"></a>
236
+
237
+ ### `CommandHandler` (callback)
238
+
239
+ A registered action. It runs at the start of the tick it was scheduled for.
240
+
241
+ Game code supplies this function.
242
+
243
+ ```ts
244
+ type CommandHandler = (world: World, args: readonly string[]) => void
245
+ ```
246
+
247
+ | Parameter | Type | Optional | Doc |
248
+ |---|---|---|---|
249
+ | `world` | `World` | no | The world. |
250
+ | `args` | `readonly string[]` | no | The `:`-separated arguments after the action name. |
251
+
252
+ ```ogt
253
+ callback CommandHandler {
254
+ doc "A registered action. It runs at the start of the tick it was scheduled for."
255
+ param world World "The world."
256
+ param args List.String "The `:`-separated arguments after the action name."
257
+ }
258
+ ```
259
+
260
+ <sub>`api.ogt` line 10394</sub>
261
+
262
+ <a id="type-CommandDesc"></a>
263
+
264
+ ### `CommandDesc` (desc struct)
265
+
266
+ How a registered action describes itself in `og run --help` and the wiki.
267
+
268
+ A desc: every field may be omitted and takes its default; `{}` is valid.
269
+
270
+ | Field | Type | Default | Range | Unit | Notes | Doc |
271
+ |---|---|---|---|---|---|---|
272
+ | `usage` | `string` | `""` | — | — | — | The argument form, such as `<count>`. |
273
+ | `doc` | `string` | `""` | — | — | — | One sentence on what it does. |
274
+
275
+ ```ogt
276
+ struct CommandDesc {
277
+ doc "How a registered action describes itself in `og run --help` and the wiki."
278
+ desc true
279
+ field usage String "The argument form, such as `<count>`."
280
+ field doc String "One sentence on what it does."
281
+ }
282
+ ```
283
+
284
+ <sub>`api.ogt` line 10400</sub>
285
+
286
+ <a id="type-CommandStep"></a>
287
+
288
+ ### `CommandStep` (struct)
289
+
290
+ One parsed step of a command script.
291
+
292
+ | Field | Type | Default | Range | Unit | Notes | Doc |
293
+ |---|---|---|---|---|---|---|
294
+ | `at` | `number` | `0` | — | `s` | — | When it runs, in simulation seconds from the start of the script. |
295
+ | `action` | `string` | `""` | — | — | — | The action name. |
296
+ | `args` | `readonly string[]` | `[]` | — | — | — | The arguments. |
297
+
298
+ ```ogt
299
+ struct CommandStep {
300
+ doc "One parsed step of a command script."
301
+ field at f32 "When it runs, in simulation seconds from the start of the script." {
302
+ unit s
303
+ }
304
+ field action String "The action name."
305
+ field args List.String "The arguments."
306
+ }
307
+ ```
308
+
309
+ <sub>`api.ogt` line 10407</sub>
310
+
311
+ <a id="type-CommandInfo"></a>
312
+
313
+ ### `CommandInfo` (struct)
314
+
315
+ One action as help lists it.
316
+
317
+ | Field | Type | Default | Range | Unit | Notes | Doc |
318
+ |---|---|---|---|---|---|---|
319
+ | `name` | `string` | `""` | — | — | — | The action name. |
320
+ | `usage` | `string` | `""` | — | — | — | Its argument form, such as `screenshot[:path][:full\|:N]`. |
321
+ | `doc` | `string` | `""` | — | — | — | One sentence on what it does. |
322
+ | `core` | `boolean` | `false` | — | — | — | Shipped with the engine (true) or registered by a module or a game. |
323
+
324
+ ```ogt
325
+ struct CommandInfo {
326
+ doc "One action as help lists it."
327
+ field name String "The action name."
328
+ field usage String "Its argument form, such as `screenshot[:path][:full|:N]`."
329
+ field doc String "One sentence on what it does."
330
+ field core bool "Shipped with the engine (true) or registered by a module or a game."
331
+ }
332
+ ```
333
+
334
+ <sub>`api.ogt` line 10416</sub>
335
+
336
+ <a id="type-CommandsReport"></a>
337
+
338
+ ### `CommandsReport` (struct)
339
+
340
+ What scheduling a script did.
341
+
342
+ | Field | Type | Default | Range | Unit | Notes | Doc |
343
+ |---|---|---|---|---|---|---|
344
+ | `scheduled` | `number` | `0` | — | — | — | Steps scheduled. |
345
+ | `untilTick` | `number` | `0` | — | — | — | The tick of the last step. |
346
+ | `warnings` | `readonly string[]` | `[]` | — | — | — | Unknown actions and other skipped steps, each naming the fix. |
347
+
348
+ ```ogt
349
+ struct CommandsReport {
350
+ doc "What scheduling a script did."
351
+ field scheduled u32 "Steps scheduled."
352
+ field untilTick u32 "The tick of the last step."
353
+ field warnings List.String "Unknown actions and other skipped steps, each naming the fix."
354
+ }
355
+ ```
356
+
357
+ <sub>`api.ogt` line 10424</sub>
@@ -0,0 +1,220 @@
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 `game` module
4
+
5
+ The game entry: what the bundle's default export declares.
6
+
7
+ - **TypeScript**: functions are members of the root object `og` (`og.<fn>`); components, resources and events are tokens on `og`.
8
+ - **Publish builds**: kept (members may override).
9
+ - **Skill**: `og-game`, which teaches the module (how much of it to use, and how to prove it).
10
+ - **Index**: [every module and name](index.md).
11
+
12
+ ```ogt
13
+ module game {
14
+ # declarations follow, each quoted below
15
+ ```
16
+
17
+ <sub>`api.ogt` line 460</sub>
18
+
19
+ ## Contents
20
+
21
+ | Name | Kind | Summary |
22
+ |---|---|---|
23
+ | [`FactsFn`](#type-FactsFn) | callback | The game's own facts for the probe's state(): a small JSON object, computed from the world without changing it. |
24
+ | [`StartFn`](#type-StartFn) | callback | The game's setup: called once before the first tick, after GameDesc.scene has spawned. Spawn, insert, load and set resources here; systems then only read and write their views. |
25
+ | [`GameDesc`](#type-GameDesc) | desc struct | A game: its tick, scenes, systems and commands. |
26
+ | [`Game`](#type-Game) | interface | A declared game, the bundle's default export. |
27
+ | [`og.game`](#fn-game) | function | Declare the game. The bundle's default export is its result. |
28
+
29
+ ## Functions
30
+
31
+ <a id="fn-game"></a>
32
+
33
+ ### `og.game`
34
+
35
+ Declare the game. The bundle's default export is its result.
36
+
37
+ ```ts
38
+ og.game(desc?: GameDesc): Game
39
+ ```
40
+
41
+ | Parameter | Type | Optional | Doc |
42
+ |---|---|---|---|
43
+ | `desc` | `GameDesc` | yes | Tick, scenes, systems and commands. |
44
+
45
+ **Returns** `Game`.
46
+
47
+ Binding symbol `og_game_game` · publish builds: kept
48
+
49
+ ```ogt
50
+ fn game {
51
+ doc "Declare the game. The bundle's default export is its result."
52
+ param desc GameDesc "Tick, scenes, systems and commands."
53
+ returns Game
54
+ }
55
+ ```
56
+
57
+ <sub>`api.ogt` line 512</sub>
58
+
59
+ ## Interfaces
60
+
61
+ <a id="type-Game"></a>
62
+
63
+ ### `Game` (interface)
64
+
65
+ A declared game, the bundle's default export.
66
+
67
+ ```ogt
68
+ interface Game {
69
+ doc "A declared game, the bundle's default export."
70
+ # members follow, each quoted below
71
+ ```
72
+
73
+ <sub>`api.ogt` line 506</sub>
74
+
75
+ <a id="member-Game-tick"></a>
76
+
77
+ #### `Game.tick` (property)
78
+
79
+ GameDesc.tick, or 60 when it is unset (the engine then runs at project.ogt's `tick` when the host passes the project, as og run and og build do).
80
+
81
+ ```ts
82
+ readonly tick: number
83
+ ```
84
+
85
+ Binding symbol `og_game_get_tick` · publish builds: kept
86
+
87
+ ```ogt
88
+ prop tick u32 "GameDesc.tick, or 60 when it is unset (the engine then runs at project.ogt's `tick` when the host passes the project, as og run and og build do)."
89
+ ```
90
+
91
+ <sub>`api.ogt` line 508</sub>
92
+
93
+ <a id="member-Game-systems"></a>
94
+
95
+ #### `Game.systems` (property)
96
+
97
+ The systems in declaration order.
98
+
99
+ ```ts
100
+ readonly systems: readonly System[]
101
+ ```
102
+
103
+ Binding symbol `og_game_get_systems` · publish builds: kept
104
+
105
+ ```ogt
106
+ prop systems List.System "The systems in declaration order."
107
+ ```
108
+
109
+ <sub>`api.ogt` line 509</sub>
110
+
111
+ ## Types
112
+
113
+ <a id="type-FactsFn"></a>
114
+
115
+ ### `FactsFn` (callback)
116
+
117
+ The game's own facts for the probe's state(): a small JSON object, computed from the world without changing it.
118
+
119
+ Game code supplies this function.
120
+
121
+ ```ts
122
+ type FactsFn = (world: World) => unknown
123
+ ```
124
+
125
+ | Parameter | Type | Optional | Doc |
126
+ |---|---|---|---|
127
+ | `world` | `World` | no | The world, read only. |
128
+
129
+ ```ogt
130
+ callback FactsFn {
131
+ doc "The game's own facts for the probe's state(): a small JSON object, computed from the world without changing it."
132
+ param world World "The world, read only."
133
+ returns Json
134
+ }
135
+ ```
136
+
137
+ <sub>`api.ogt` line 465</sub>
138
+
139
+ <a id="type-StartFn"></a>
140
+
141
+ ### `StartFn` (callback)
142
+
143
+ The game's setup: called once before the first tick, after GameDesc.scene has spawned. Spawn, insert, load and set resources here; systems then only read and write their views.
144
+
145
+ Game code supplies this function.
146
+
147
+ ```ts
148
+ type StartFn = (world: World) => void
149
+ ```
150
+
151
+ | Parameter | Type | Optional | Doc |
152
+ |---|---|---|---|
153
+ | `world` | `World` | no | The world. |
154
+
155
+ ```ogt
156
+ callback StartFn {
157
+ doc "The game's setup: called once before the first tick, after GameDesc.scene has spawned. Spawn, insert, load and set resources here; systems then only read and write their views."
158
+ param world World "The world."
159
+ }
160
+ ```
161
+
162
+ <sub>`api.ogt` line 471</sub>
163
+
164
+ <a id="type-GameDesc"></a>
165
+
166
+ ### `GameDesc` (desc struct)
167
+
168
+ A game: its tick, scenes, systems and commands.
169
+
170
+ A desc: every field may be omitted and takes its default; `{}` is valid.
171
+
172
+ | Field | Type | Default | Range | Unit | Notes | Doc |
173
+ |---|---|---|---|---|---|---|
174
+ | `tick` | `number` | `60` | 1 … 240 | `hz` | — | The fixed tick rate. Left unset, project.ogt's `tick` applies (else 60); tick, seed, scenes and scene set both here and in project.ogt to different values refuse the engine, naming both. |
175
+ | `seed` | `number` | `0` | — | — | — | The project seed every Rng stream derives from; left unset, project.ogt's `seed` (else 0). A replay overrides it. |
176
+ | `scenes` | `Readonly<Record<string, string>>` | `{}` | — | — | — | Scene names to `.ogt` paths, as `{ main: "scenes/main.ogt" }`; left unset, project.ogt's `scenes` block. |
177
+ | `scene` | `string` | `"main"` | — | — | — | The scene loaded first; left unset, project.ogt's `scene` (else main). |
178
+ | `systems` | `readonly System[]` | `[]` | — | — | — | The systems, in declaration order before `after`/`before` constraints apply. |
179
+ | `resources` | `readonly AnyResource[]` | `[]` | — | — | — | The game's own resources, created at their defaults. |
180
+ | `commands` | `Readonly<Record<string, CommandHandler>>` | `{}` | — | — | — | Game actions registered into the command channel, by action name. |
181
+ | `commandHelp` | `Readonly<Record<string, CommandDesc>>` | `{}` | — | — | — | Each game action's argument form and one sentence, by its name in commands, for `help`: `{ place: { usage: "<x>:<y>", doc: "Move the hero there." } }`. An action without an entry is listed by name alone. |
182
+ | `maxCatchUp` | `number` | `4` | 1 … 60 | `ticks` | — | The most ticks one frame may run to catch up with the clock; the accumulator drops the rest. |
183
+ | `facts` | `FactsFn \| null` | `null` | — | — | — | The game's own facts for the probe's state(). |
184
+ | `start` | `StartFn \| null` | `null` | — | — | — | Called once before the first tick, after the first scene spawned. A throw fails the run: no tick runs on the half-built world, `og run`, `og test` and `og dev` exit non-zero naming the error with its stack, and the web shell shows it. |
185
+ | `render` | `RenderOptions` | `{}` | — | — | — | How the renderer is created: antialiasing and shadow map size. Read once, when the host attaches the renderer. |
186
+ | `look` | `string` | `""` | — | — | — | A look (`looks/<name>.ogt`, og.load.look) applied after the first scene spawned and before start runs, so start may still change any of it; its antialias is the renderer's when render leaves antialias out. Empty applies none. |
187
+
188
+ ```ogt
189
+ struct GameDesc {
190
+ doc "A game: its tick, scenes, systems and commands."
191
+ desc true
192
+ field tick u32 "The fixed tick rate. Left unset, project.ogt's `tick` applies (else 60); tick, seed, scenes and scene set both here and in project.ogt to different values refuse the engine, naming both." {
193
+ default 60
194
+ min 1
195
+ max 240
196
+ unit hz
197
+ }
198
+ field seed u32 "The project seed every Rng stream derives from; left unset, project.ogt's `seed` (else 0). A replay overrides it."
199
+ field scenes Map.String "Scene names to `.ogt` paths, as `{ main: \"scenes/main.ogt\" }`; left unset, project.ogt's `scenes` block."
200
+ field scene String "The scene loaded first; left unset, project.ogt's `scene` (else main)." {
201
+ default "main"
202
+ }
203
+ field systems List.System "The systems, in declaration order before `after`/`before` constraints apply."
204
+ field resources List.AnyResource "The game's own resources, created at their defaults."
205
+ field commands Map.CommandHandler "Game actions registered into the command channel, by action name."
206
+ field commandHelp Map.CommandDesc "Each game action's argument form and one sentence, by its name in commands, for `help`: `{ place: { usage: \"<x>:<y>\", doc: \"Move the hero there.\" } }`. An action without an entry is listed by name alone."
207
+ field maxCatchUp u32 "The most ticks one frame may run to catch up with the clock; the accumulator drops the rest." {
208
+ default 4
209
+ min 1
210
+ max 60
211
+ unit ticks
212
+ }
213
+ field facts Option.FactsFn "The game's own facts for the probe's state()."
214
+ field start Option.StartFn "Called once before the first tick, after the first scene spawned. A throw fails the run: no tick runs on the half-built world, `og run`, `og test` and `og dev` exit non-zero naming the error with its stack, and the web shell shows it."
215
+ field render RenderOptions "How the renderer is created: antialiasing and shadow map size. Read once, when the host attaches the renderer."
216
+ field look String "A look (`looks/<name>.ogt`, og.load.look) applied after the first scene spawned and before start runs, so start may still change any of it; its antialias is the renderer's when render leaves antialias out. Empty applies none."
217
+ }
218
+ ```
219
+
220
+ <sub>`api.ogt` line 476</sub>