@origingame/engine 0.1.1 → 0.3.0

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 (109) hide show
  1. package/bin/og.mjs +1 -1
  2. package/dist/web/origin-engine.d.ts +219 -5
  3. package/dist/web/origin-engine.js +1344 -125
  4. package/dist/web/origin-engine_bg.wasm +0 -0
  5. package/dist/web/origin-engine_bg.wasm.d.ts +68 -3
  6. package/dist/web-publish/origin-engine-lanes.js +1007 -22
  7. package/dist/web-publish/origin-engine-lanes_bg.wasm +0 -0
  8. package/dist/web-publish/origin-engine.d.ts +162 -5
  9. package/dist/web-publish/origin-engine.js +1004 -19
  10. package/dist/web-publish/origin-engine_bg.wasm +0 -0
  11. package/dist/web-publish/origin-engine_bg.wasm.d.ts +52 -3
  12. package/dist/web-publish-2d/origin-engine-lanes.js +1007 -22
  13. package/dist/web-publish-2d/origin-engine-lanes_bg.wasm +0 -0
  14. package/dist/web-publish-2d/origin-engine.d.ts +162 -5
  15. package/dist/web-publish-2d/origin-engine.js +1004 -19
  16. package/dist/web-publish-2d/origin-engine_bg.wasm +0 -0
  17. package/dist/web-publish-2d/origin-engine_bg.wasm.d.ts +52 -3
  18. package/knowledge/looks/catalogue.json +40 -40
  19. package/knowledge/package.json +4 -4
  20. package/knowledge/scaffold/distribution.json +14 -0
  21. package/knowledge/scaffold/origin-engine.json +2 -2
  22. package/knowledge/scaffold/template/README.md +2 -1
  23. package/knowledge/scaffold/template/assets/audio/sting.ogt +10 -0
  24. package/knowledge/scaffold/template/assets/timelines/intro.ogt +101 -0
  25. package/knowledge/scaffold/template/assets/timelines/narration.srt +11 -0
  26. package/knowledge/scaffold/template/host.d.ts +46 -0
  27. package/knowledge/scaffold/template/package.json +1 -1
  28. package/knowledge/scaffold/template/project.ogt +1 -1
  29. package/knowledge/scaffold/template/src/main.ts +1 -1
  30. package/knowledge/scaffold/template/tests/frames.ts +134 -0
  31. package/knowledge/scaffold/template/tests/intro.og.ts +65 -0
  32. package/knowledge/scaffold/template/tests/smoke.og.ts +30 -36
  33. package/knowledge/scaffold/template/tsconfig.json +1 -1
  34. package/knowledge/scripts/mount.ts +2 -1
  35. package/knowledge/scripts/validate.ts +21 -11
  36. package/knowledge/skills/og-build/SKILL.md +25 -6
  37. package/knowledge/skills/og-core/SKILL.md +11 -0
  38. package/knowledge/skills/og-feel/SKILL.md +8 -1
  39. package/knowledge/skills/og-game/SKILL.md +994 -21
  40. package/knowledge/skills/og-i18n/SKILL.md +12 -3
  41. package/knowledge/skills/og-platform-sdk/SKILL.md +4 -1
  42. package/knowledge/skills/og-taste/SKILL.md +82 -73
  43. package/knowledge/skills/og-ui/SKILL.md +82 -54
  44. package/knowledge/wiki/ai.md +20 -20
  45. package/knowledge/wiki/anim.md +384 -41
  46. package/knowledge/wiki/atmosphere.md +36 -13
  47. package/knowledge/wiki/audio.md +18 -18
  48. package/knowledge/wiki/camera.md +19 -13
  49. package/knowledge/wiki/commands.md +19 -13
  50. package/knowledge/wiki/debug.md +414 -0
  51. package/knowledge/wiki/game.md +8 -8
  52. package/knowledge/wiki/i18n.md +7 -7
  53. package/knowledge/wiki/index.md +265 -7
  54. package/knowledge/wiki/input.md +47 -47
  55. package/knowledge/wiki/load.md +236 -68
  56. package/knowledge/wiki/math.md +2614 -7
  57. package/knowledge/wiki/nav.md +34 -34
  58. package/knowledge/wiki/net.md +340 -0
  59. package/knowledge/wiki/path.md +402 -0
  60. package/knowledge/wiki/physics.md +124 -106
  61. package/knowledge/wiki/platform.md +465 -31
  62. package/knowledge/wiki/probe.md +681 -67
  63. package/knowledge/wiki/reflect.md +15 -15
  64. package/knowledge/wiki/render.md +3904 -1897
  65. package/knowledge/wiki/rng.md +14 -14
  66. package/knowledge/wiki/stream.md +15 -15
  67. package/knowledge/wiki/system.md +8 -8
  68. package/knowledge/wiki/systems.md +2 -2
  69. package/knowledge/wiki/terrain.md +19 -19
  70. package/knowledge/wiki/tilemap.md +19 -15
  71. package/knowledge/wiki/time.md +4 -4
  72. package/knowledge/wiki/timeline.md +396 -0
  73. package/knowledge/wiki/transform.md +8 -8
  74. package/knowledge/wiki/tween.md +17 -17
  75. package/knowledge/wiki/ui.md +603 -629
  76. package/knowledge/wiki/video.md +157 -0
  77. package/knowledge/wiki/world.md +67 -37
  78. package/package.json +7 -6
  79. package/schema/api.schema.json +21071 -13964
  80. package/shell/page.ts +26 -2
  81. package/shell/platform.ts +46 -0
  82. package/shell/player.ts +7 -0
  83. package/src/depth.ts +71 -0
  84. package/src/e6.ts +32 -1
  85. package/src/env.d.ts +5 -1
  86. package/src/generated/abi.ts +189 -3
  87. package/src/index.ts +26 -4
  88. package/src/light.ts +18 -0
  89. package/src/math.ts +622 -0
  90. package/src/node/index.ts +17 -0
  91. package/src/node/playtest-run.ts +114 -18
  92. package/src/node/polish.ts +15 -4
  93. package/src/node/render.ts +291 -0
  94. package/src/node/run.ts +91 -6
  95. package/src/p2.ts +19 -1
  96. package/src/playtest.ts +57 -4
  97. package/src/runtime.ts +15 -3
  98. package/src/targets.ts +28 -0
  99. package/src/trace.ts +169 -0
  100. package/src/ui-kit/huds.ts +49 -45
  101. package/src/ui-kit/menus.ts +12 -12
  102. package/src/ui-kit/settings.ts +2 -2
  103. package/src/ui-kit/store.ts +18 -18
  104. package/src/ui-kit/story.ts +6 -4
  105. package/src/ui-kit/util.ts +8 -8
  106. package/src/web/shell.ts +58 -0
  107. package/src/web/worker.ts +103 -2
  108. package/types/bindings.json +8945 -6456
  109. package/types/index.d.ts +15507 -11437
@@ -18,7 +18,7 @@ module nav {
18
18
  # declarations follow, each quoted below
19
19
  ```
20
20
 
21
- <sub>`api.ogt` line 6798</sub>
21
+ <sub>`api.ogt` line 8459</sub>
22
22
 
23
23
  ## Contents
24
24
 
@@ -88,7 +88,7 @@ fn grid {
88
88
  }
89
89
  ```
90
90
 
91
- <sub>`api.ogt` line 7154</sub>
91
+ <sub>`api.ogt` line 8815</sub>
92
92
 
93
93
  <a id="fn-gridFromTilemap"></a>
94
94
 
@@ -118,7 +118,7 @@ fn gridFromTilemap {
118
118
  }
119
119
  ```
120
120
 
121
- <sub>`api.ogt` line 7161</sub>
121
+ <sub>`api.ogt` line 8822</sub>
122
122
 
123
123
  <a id="fn-setCost"></a>
124
124
 
@@ -154,7 +154,7 @@ fn setCost {
154
154
  }
155
155
  ```
156
156
 
157
- <sub>`api.ogt` line 7168</sub>
157
+ <sub>`api.ogt` line 8829</sub>
158
158
 
159
159
  <a id="fn-cellAt"></a>
160
160
 
@@ -186,7 +186,7 @@ fn cellAt {
186
186
  }
187
187
  ```
188
188
 
189
- <sub>`api.ogt` line 7178</sub>
189
+ <sub>`api.ogt` line 8839</sub>
190
190
 
191
191
  <a id="fn-findPath"></a>
192
192
 
@@ -216,7 +216,7 @@ fn findPath {
216
216
  }
217
217
  ```
218
218
 
219
- <sub>`api.ogt` line 7186</sub>
219
+ <sub>`api.ogt` line 8847</sub>
220
220
 
221
221
  <a id="fn-flowField"></a>
222
222
 
@@ -246,7 +246,7 @@ fn flowField {
246
246
  }
247
247
  ```
248
248
 
249
- <sub>`api.ogt` line 7193</sub>
249
+ <sub>`api.ogt` line 8854</sub>
250
250
 
251
251
  <a id="fn-setFlowTargets"></a>
252
252
 
@@ -278,7 +278,7 @@ fn setFlowTargets {
278
278
  }
279
279
  ```
280
280
 
281
- <sub>`api.ogt` line 7200</sub>
281
+ <sub>`api.ogt` line 8861</sub>
282
282
 
283
283
  <a id="fn-flowAt"></a>
284
284
 
@@ -310,7 +310,7 @@ fn flowAt {
310
310
  }
311
311
  ```
312
312
 
313
- <sub>`api.ogt` line 7208</sub>
313
+ <sub>`api.ogt` line 8869</sub>
314
314
 
315
315
  <a id="fn-load"></a>
316
316
 
@@ -340,7 +340,7 @@ fn load {
340
340
  }
341
341
  ```
342
342
 
343
- <sub>`api.ogt` line 7216</sub>
343
+ <sub>`api.ogt` line 8877</sub>
344
344
 
345
345
  <a id="fn-build"></a>
346
346
 
@@ -370,7 +370,7 @@ fn build {
370
370
  }
371
371
  ```
372
372
 
373
- <sub>`api.ogt` line 7223</sub>
373
+ <sub>`api.ogt` line 8884</sub>
374
374
 
375
375
  <a id="fn-setObstacle"></a>
376
376
 
@@ -406,7 +406,7 @@ fn setObstacle {
406
406
  }
407
407
  ```
408
408
 
409
- <sub>`api.ogt` line 7230</sub>
409
+ <sub>`api.ogt` line 8891</sub>
410
410
 
411
411
  <a id="fn-nearest"></a>
412
412
 
@@ -442,7 +442,7 @@ fn nearest {
442
442
  }
443
443
  ```
444
444
 
445
- <sub>`api.ogt` line 7241</sub>
445
+ <sub>`api.ogt` line 8902</sub>
446
446
 
447
447
  <a id="fn-pathOf"></a>
448
448
 
@@ -472,7 +472,7 @@ fn pathOf {
472
472
  }
473
473
  ```
474
474
 
475
- <sub>`api.ogt` line 7252</sub>
475
+ <sub>`api.ogt` line 8913</sub>
476
476
 
477
477
  ## Components, resources and events
478
478
 
@@ -593,7 +593,7 @@ component NavAgent {
593
593
  }
594
594
  ```
595
595
 
596
- <sub>`api.ogt` line 6825</sub>
596
+ <sub>`api.ogt` line 8486</sub>
597
597
 
598
598
  <a id="record-Steering"></a>
599
599
 
@@ -720,7 +720,7 @@ component Steering {
720
720
  }
721
721
  ```
722
722
 
723
- <sub>`api.ogt` line 6910</sub>
723
+ <sub>`api.ogt` line 8571</sub>
724
724
 
725
725
  ## Types
726
726
 
@@ -736,7 +736,7 @@ A generational handle: a number the engine hands out. A dead handle is an error
736
736
  handle Navigation "A grid, a navmesh or a flow field agents plan on."
737
737
  ```
738
738
 
739
- <sub>`api.ogt` line 6804</sub>
739
+ <sub>`api.ogt` line 8465</sub>
740
740
 
741
741
  <a id="type-NavAlgorithm"></a>
742
742
 
@@ -759,7 +759,7 @@ enum NavAlgorithm {
759
759
  }
760
760
  ```
761
761
 
762
- <sub>`api.ogt` line 6819</sub>
762
+ <sub>`api.ogt` line 8480</sub>
763
763
 
764
764
  <a id="type-NavGridDesc"></a>
765
765
 
@@ -804,7 +804,7 @@ struct NavGridDesc {
804
804
  }
805
805
  ```
806
806
 
807
- <sub>`api.ogt` line 7004</sub>
807
+ <sub>`api.ogt` line 8665</sub>
808
808
 
809
809
  <a id="type-TilemapGridDesc"></a>
810
810
 
@@ -832,7 +832,7 @@ struct TilemapGridDesc {
832
832
  }
833
833
  ```
834
834
 
835
- <sub>`api.ogt` line 7029</sub>
835
+ <sub>`api.ogt` line 8690</sub>
836
836
 
837
837
  <a id="type-NavCell"></a>
838
838
 
@@ -855,7 +855,7 @@ struct NavCell {
855
855
  }
856
856
  ```
857
857
 
858
- <sub>`api.ogt` line 7039</sub>
858
+ <sub>`api.ogt` line 8700</sub>
859
859
 
860
860
  <a id="type-PathDesc"></a>
861
861
 
@@ -897,7 +897,7 @@ struct PathDesc {
897
897
  }
898
898
  ```
899
899
 
900
- <sub>`api.ogt` line 7046</sub>
900
+ <sub>`api.ogt` line 8707</sub>
901
901
 
902
902
  <a id="type-NavPath"></a>
903
903
 
@@ -926,7 +926,7 @@ struct NavPath {
926
926
  }
927
927
  ```
928
928
 
929
- <sub>`api.ogt` line 7067</sub>
929
+ <sub>`api.ogt` line 8728</sub>
930
930
 
931
931
  <a id="type-FlowDesc"></a>
932
932
 
@@ -950,7 +950,7 @@ struct FlowDesc {
950
950
  }
951
951
  ```
952
952
 
953
- <sub>`api.ogt` line 7078</sub>
953
+ <sub>`api.ogt` line 8739</sub>
954
954
 
955
955
  <a id="type-NavBox"></a>
956
956
 
@@ -978,7 +978,7 @@ struct NavBox {
978
978
  }
979
979
  ```
980
980
 
981
- <sub>`api.ogt` line 7085</sub>
981
+ <sub>`api.ogt` line 8746</sub>
982
982
 
983
983
  <a id="type-NavMeshDesc"></a>
984
984
 
@@ -1036,7 +1036,7 @@ struct NavMeshDesc {
1036
1036
  }
1037
1037
  ```
1038
1038
 
1039
- <sub>`api.ogt` line 7096</sub>
1039
+ <sub>`api.ogt` line 8757</sub>
1040
1040
 
1041
1041
  <a id="type-NavMeshInfo"></a>
1042
1042
 
@@ -1071,7 +1071,7 @@ struct NavMeshInfo {
1071
1071
  }
1072
1072
  ```
1073
1073
 
1074
- <sub>`api.ogt` line 7132</sub>
1074
+ <sub>`api.ogt` line 8793</sub>
1075
1075
 
1076
1076
  <a id="type-NavRebuild"></a>
1077
1077
 
@@ -1092,7 +1092,7 @@ struct NavRebuild {
1092
1092
  }
1093
1093
  ```
1094
1094
 
1095
- <sub>`api.ogt` line 7148</sub>
1095
+ <sub>`api.ogt` line 8809</sub>
1096
1096
 
1097
1097
  ## Column kinds
1098
1098
 
@@ -1111,7 +1111,7 @@ column Navigation {
1111
1111
  }
1112
1112
  ```
1113
1113
 
1114
- <sub>`api.ogt` line 6806</sub>
1114
+ <sub>`api.ogt` line 8467</sub>
1115
1115
 
1116
1116
  ## Constants
1117
1117
 
@@ -1127,28 +1127,28 @@ column Navigation {
1127
1127
  const NAV_IDLE u32 0 "NavAgent.status: not seeking."
1128
1128
  ```
1129
1129
 
1130
- <sub>`api.ogt` line 6813</sub>
1130
+ <sub>`api.ogt` line 8474</sub>
1131
1131
 
1132
1132
  ```ogt
1133
1133
  const NAV_MOVING u32 1 "NavAgent.status: following a path or a flow field."
1134
1134
  ```
1135
1135
 
1136
- <sub>`api.ogt` line 6814</sub>
1136
+ <sub>`api.ogt` line 8475</sub>
1137
1137
 
1138
1138
  ```ogt
1139
1139
  const NAV_ARRIVED u32 2 "NavAgent.status: within stopDistance of the target."
1140
1140
  ```
1141
1141
 
1142
- <sub>`api.ogt` line 6815</sub>
1142
+ <sub>`api.ogt` line 8476</sub>
1143
1143
 
1144
1144
  ```ogt
1145
1145
  const NAV_UNREACHABLE u32 3 "NavAgent.status: no path reaches the target, or the agent is off its grid or navmesh."
1146
1146
  ```
1147
1147
 
1148
- <sub>`api.ogt` line 6816</sub>
1148
+ <sub>`api.ogt` line 8477</sub>
1149
1149
 
1150
1150
  ```ogt
1151
1151
  const NAV_PARTIAL u32 4 "NavAgent.status: the target is cut off; moving to the reachable point nearest it."
1152
1152
  ```
1153
1153
 
1154
- <sub>`api.ogt` line 6817</sub>
1154
+ <sub>`api.ogt` line 8478</sub>
@@ -0,0 +1,340 @@
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 `net` module
4
+
5
+ Deterministic lockstep over a room (docs/design.md §2.10): every peer runs the whole world, and what crosses the room is each player's input, one per tick, and the world's hash. Turn it on with og.Lockstep (`enabled`, `players`); join a room (og.platform.roomJoin, or `og run --room ws://127.0.0.1:P/<room>` with `og relay` natively). Until the room holds `players` peers the world runs freely on each (a lobby, the local input driving the local player); then the authority (the lowest peer number) starts: every other peer takes its world's snapshot, the seats go to the peers in number order, and from then on tick t runs only when every seated player's input for t is in. A peer that joins a running room takes a free seat (or watches) from a snapshot a running peer hands it.
6
+
7
+ Inputs are og.PlayerInput: one entity per player carries it with `player` set to its seat; the engine writes every other field at the start of each tick from that seat's input for the tick. A system reads the inputs from og.PlayerInput, never from og.Input, and gives this peer's own with og.net.submit (from a system that reads og.Input: what the local player holds now, sent for the tick inputDelay ticks on). Without a room, or with lockstep off, og.net.submit drives the local player's og.PlayerInput the next tick, so the same game plays alone.
8
+
9
+ Every tick each peer hashes its world without its own session (og.Input, og.Pointers, og.Gamepad, og.Audio, og.Camera, og.Lockstep, the input, room, platform, asset and stream events, the UI's focus and hover) and every hashEvery ticks sends the hashes since its last batch; the first tick whose hashes differ is reported once as og.Desync, and the probe's `desync` dump (`dump_desync`) names it with the component-level diff of the two peers' snapshots of that tick: the answer to what is not deterministic (Math.random, Date.now, a wall clock, iteration over a Set of objects, a module variable, input read from og.Input).
10
+
11
+ - **TypeScript**: functions are the namespace `og.net`; components, resources and events are tokens on `og`.
12
+ - **Publish builds**: kept (members may override).
13
+ - **Skill**: `og-game`, 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 net {
18
+ # declarations follow, each quoted below
19
+ ```
20
+
21
+ <sub>`api.ogt` line 13767</sub>
22
+
23
+ ## Contents
24
+
25
+ | Name | Kind | Summary |
26
+ |---|---|---|
27
+ | [`og.Lockstep`](#record-Lockstep) | resource | Lockstep's settings and this peer's place. The game sets enabled, players, inputDelay and hashEvery (the authority's are the room's once it starts: changes while running wait for the next start); the engine sets localPlayer and running. It is this peer's own: never hashed, never compared. |
28
+ | [`og.PlayerInput`](#record-PlayerInput) | component | One player's input for this tick, the same on every peer: the engine writes every field but `player` at the start of each tick from the seat's input (zero for a seat nobody holds, and before its holder's first input). Its packed bytes are what crosses the room, read through this layout. |
29
+ | [`og.Desync`](#record-Desync) | event | This peer's world and another's differ: sent once, at the start of the tick after the hashes showed it. The probe's `desync` dump (`dump_desync`) names the component and field that differ, once the other peer's snapshot of that tick arrived. |
30
+ | [`InputDesc`](#type-InputDesc) | desc struct | This peer's player's input: og.PlayerInput's fields but `player` and `tick`. |
31
+ | [`LockstepSeat`](#type-LockstepSeat) | struct | One peer's hold on a seat. |
32
+ | [`LockstepStatus`](#type-LockstepStatus) | struct | Lockstep on this peer, as the probe and a HUD read it. |
33
+ | [`og.net.submit`](#fn-submit) | function | Give this peer's player's input: in lockstep, for the tick inputDelay ticks from the one running (sent to every peer when the tick ends); otherwise, for the next tick. It holds until the next call, so a game calls it once a tick from a system that reads og.Input (or og.Gamepad, or the UI's touch controls). Callable from a system. |
34
+ | [`og.net.status`](#fn-status) | function | Lockstep on this peer: running, the seats and who it waits for. |
35
+ | [`og.net.hash`](#fn-hash) | function | The world's shared hash now, hex: the hash lockstep compares, which leaves this peer's session out (og.Input, og.Lockstep, input and room events, the UI's focus; module docs). Two peers at the same tick agree on it exactly when their simulations agree; the world dump's `hash` covers everything and differs between peers. |
36
+
37
+ ## Functions
38
+
39
+ <a id="fn-submit"></a>
40
+
41
+ ### `og.net.submit`
42
+
43
+ Give this peer's player's input: in lockstep, for the tick inputDelay ticks from the one running (sent to every peer when the tick ends); otherwise, for the next tick. It holds until the next call, so a game calls it once a tick from a system that reads og.Input (or og.Gamepad, or the UI's touch controls). Callable from a system.
44
+
45
+ ```ts
46
+ og.net.submit(world: World, input?: InputDesc): Result<void>
47
+ ```
48
+
49
+ | Parameter | Type | Optional | Doc |
50
+ |---|---|---|---|
51
+ | `world` | `World` | no | The world. |
52
+ | `input` | `InputDesc` | yes | The buttons and axes. |
53
+
54
+ **Returns** `Result<void>`: Refused for an axis that is not finite.
55
+
56
+ Binding symbol `og_net_submit` · publish builds: kept
57
+
58
+ ```ogt
59
+ fn submit {
60
+ doc "Give this peer's player's input: in lockstep, for the tick inputDelay ticks from the one running (sent to every peer when the tick ends); otherwise, for the next tick. It holds until the next call, so a game calls it once a tick from a system that reads og.Input (or og.Gamepad, or the UI's touch controls). Callable from a system."
61
+ param world World "The world."
62
+ param input InputDesc "The buttons and axes."
63
+ returns Result.Void "Refused for an axis that is not finite."
64
+ }
65
+ ```
66
+
67
+ <sub>`api.ogt` line 13865</sub>
68
+
69
+ <a id="fn-status"></a>
70
+
71
+ ### `og.net.status`
72
+
73
+ Lockstep on this peer: running, the seats and who it waits for.
74
+
75
+ ```ts
76
+ og.net.status(world: World): LockstepStatus
77
+ ```
78
+
79
+ | Parameter | Type | Optional | Doc |
80
+ |---|---|---|---|
81
+ | `world` | `World` | no | The world. |
82
+
83
+ **Returns** `LockstepStatus`.
84
+
85
+ Binding symbol `og_net_status` · publish builds: kept
86
+
87
+ ```ogt
88
+ fn status {
89
+ doc "Lockstep on this peer: running, the seats and who it waits for."
90
+ param world World "The world."
91
+ returns LockstepStatus
92
+ }
93
+ ```
94
+
95
+ <sub>`api.ogt` line 13872</sub>
96
+
97
+ <a id="fn-hash"></a>
98
+
99
+ ### `og.net.hash`
100
+
101
+ The world's shared hash now, hex: the hash lockstep compares, which leaves this peer's session out (og.Input, og.Lockstep, input and room events, the UI's focus; module docs). Two peers at the same tick agree on it exactly when their simulations agree; the world dump's `hash` covers everything and differs between peers.
102
+
103
+ ```ts
104
+ og.net.hash(world: World): string
105
+ ```
106
+
107
+ | Parameter | Type | Optional | Doc |
108
+ |---|---|---|---|
109
+ | `world` | `World` | no | The world. |
110
+
111
+ **Returns** `string`.
112
+
113
+ Binding symbol `og_net_hash` · publish builds: kept
114
+
115
+ ```ogt
116
+ fn hash {
117
+ doc "The world's shared hash now, hex: the hash lockstep compares, which leaves this peer's session out (og.Input, og.Lockstep, input and room events, the UI's focus; module docs). Two peers at the same tick agree on it exactly when their simulations agree; the world dump's `hash` covers everything and differs between peers."
118
+ param world World "The world."
119
+ returns String
120
+ }
121
+ ```
122
+
123
+ <sub>`api.ogt` line 13878</sub>
124
+
125
+ ## Components, resources and events
126
+
127
+ <a id="record-Lockstep"></a>
128
+
129
+ ### `og.Lockstep` (resource)
130
+
131
+ Lockstep's settings and this peer's place. The game sets enabled, players, inputDelay and hashEvery (the authority's are the room's once it starts: changes while running wait for the next start); the engine sets localPlayer and running. It is this peer's own: never hashed, never compared.
132
+
133
+ Token `og.Lockstep`, registered under the schema name `og.Lockstep`; its value type is `Lockstep`.
134
+
135
+ | Field | Type | Default | Range | Unit | Notes | Doc |
136
+ |---|---|---|---|---|---|---|
137
+ | `enabled` | `boolean` | `false` | — | — | — | Whether the world takes its ticks in lockstep when in a room. |
138
+ | `players` | `number` | `2` | 1 … 16 | — | — | The seats: the peers lockstep waits for before it starts, and whose inputs each tick waits for. |
139
+ | `localPlayer` | `number` | `0` | — | — | read only | This peer's seat, the og.PlayerInput.player its input drives; `players` while it watches (a peer beyond the seats). 0 before the start. |
140
+ | `inputDelay` | `number` | `2` | 1 … 30 | `ticks` | — | Ticks between a player's input and the tick it acts on: the time the input has to cross the room. 2 (33 ms at 60 Hz) on a LAN, 4 to 6 over the internet. |
141
+ | `hashEvery` | `number` | `10` | 0 … 600 | `ticks` | — | How often the peers exchange their world hashes, in ticks (every tick is hashed, so the first divergent tick is exact); 0 compares nothing. |
142
+ | `running` | `boolean` | `false` | — | — | read only | Whether lockstep runs: the room filled the seats and the authority started (until this peer leaves the room or turns it off). |
143
+
144
+ ```ogt
145
+ resource Lockstep {
146
+ doc "Lockstep's settings and this peer's place. The game sets enabled, players, inputDelay and hashEvery (the authority's are the room's once it starts: changes while running wait for the next start); the engine sets localPlayer and running. It is this peer's own: never hashed, never compared."
147
+ field enabled bool "Whether the world takes its ticks in lockstep when in a room."
148
+ field players u32 "The seats: the peers lockstep waits for before it starts, and whose inputs each tick waits for." {
149
+ default 2
150
+ min 1
151
+ max 16
152
+ }
153
+ field localPlayer u32 "This peer's seat, the og.PlayerInput.player its input drives; `players` while it watches (a peer beyond the seats). 0 before the start." {
154
+ readonly true
155
+ }
156
+ field inputDelay u32 "Ticks between a player's input and the tick it acts on: the time the input has to cross the room. 2 (33 ms at 60 Hz) on a LAN, 4 to 6 over the internet." {
157
+ default 2
158
+ min 1
159
+ max 30
160
+ unit ticks
161
+ }
162
+ field hashEvery u32 "How often the peers exchange their world hashes, in ticks (every tick is hashed, so the first divergent tick is exact); 0 compares nothing." {
163
+ default 10
164
+ min 0
165
+ max 600
166
+ unit ticks
167
+ }
168
+ field running bool "Whether lockstep runs: the room filled the seats and the authority started (until this peer leaves the room or turns it off)." {
169
+ readonly true
170
+ }
171
+ }
172
+ ```
173
+
174
+ <sub>`api.ogt` line 13773</sub>
175
+
176
+ <a id="record-PlayerInput"></a>
177
+
178
+ ### `og.PlayerInput` (component)
179
+
180
+ One player's input for this tick, the same on every peer: the engine writes every field but `player` at the start of each tick from the seat's input (zero for a seat nobody holds, and before its holder's first input). Its packed bytes are what crosses the room, read through this layout.
181
+
182
+ Token `og.PlayerInput`, registered under the schema name `og.PlayerInput`; its value type is `PlayerInput`.
183
+
184
+ | Field | Type | Default | Range | Unit | Notes | Doc |
185
+ |---|---|---|---|---|---|---|
186
+ | `player` | `number` | `0` | — | — | — | The seat whose input this entity carries (0 to og.Lockstep.players - 1); the game sets it when it spawns the player. |
187
+ | `buttons` | `number` | `0` | — | — | — | The buttons held, one bit each, as the game numbers them (bit 0 fire, bit 1 dash, ...). |
188
+ | `x` | `number` | `0` | -1 … 1 | — | — | The move axis, left -1 to right 1. |
189
+ | `y` | `number` | `0` | -1 … 1 | — | — | The move axis, back -1 to forward 1. |
190
+ | `aimX` | `number` | `0` | — | — | — | A second axis (aim, a cursor's world x), as the game uses it. |
191
+ | `aimY` | `number` | `0` | — | — | — | A second axis (aim, a cursor's world y), as the game uses it. |
192
+ | `tick` | `number` | `0` | — | — | read only | The tick these values are for: the tick now, once the engine wrote them. |
193
+
194
+ ```ogt
195
+ component PlayerInput {
196
+ doc "One player's input for this tick, the same on every peer: the engine writes every field but `player` at the start of each tick from the seat's input (zero for a seat nobody holds, and before its holder's first input). Its packed bytes are what crosses the room, read through this layout."
197
+ field player u32 "The seat whose input this entity carries (0 to og.Lockstep.players - 1); the game sets it when it spawns the player."
198
+ field buttons u32 "The buttons held, one bit each, as the game numbers them (bit 0 fire, bit 1 dash, ...)."
199
+ field x f32 "The move axis, left -1 to right 1." {
200
+ min -1
201
+ max 1
202
+ }
203
+ field y f32 "The move axis, back -1 to forward 1." {
204
+ min -1
205
+ max 1
206
+ }
207
+ field aimX f32 "A second axis (aim, a cursor's world x), as the game uses it."
208
+ field aimY f32 "A second axis (aim, a cursor's world y), as the game uses it."
209
+ field tick u32 "The tick these values are for: the tick now, once the engine wrote them." {
210
+ readonly true
211
+ }
212
+ }
213
+ ```
214
+
215
+ <sub>`api.ogt` line 13801</sub>
216
+
217
+ <a id="record-Desync"></a>
218
+
219
+ ### `og.Desync` (event)
220
+
221
+ This peer's world and another's differ: sent once, at the start of the tick after the hashes showed it. The probe's `desync` dump (`dump_desync`) names the component and field that differ, once the other peer's snapshot of that tick arrived.
222
+
223
+ Token `og.Desync`, registered under the schema name `og.Desync`; its value type is `Desync`.
224
+
225
+ | Field | Type | Default | Range | Unit | Notes | Doc |
226
+ |---|---|---|---|---|---|---|
227
+ | `tick` | `number` | `0` | — | — | — | The first divergent tick: the world after it differs (og.Time.tick of the snapshots compared). |
228
+ | `peer` | `number` | `0` | — | — | — | The first peer whose world differs from this one. |
229
+ | `peers` | `number` | `0` | — | — | — | How many peers' worlds differ from this one. |
230
+
231
+ ```ogt
232
+ event Desync {
233
+ doc "This peer's world and another's differ: sent once, at the start of the tick after the hashes showed it. The probe's `desync` dump (`dump_desync`) names the component and field that differ, once the other peer's snapshot of that tick arrived."
234
+ field tick u32 "The first divergent tick: the world after it differs (og.Time.tick of the snapshots compared)."
235
+ field peer u32 "The first peer whose world differs from this one."
236
+ field peers u32 "How many peers' worlds differ from this one."
237
+ }
238
+ ```
239
+
240
+ <sub>`api.ogt` line 13820</sub>
241
+
242
+ ## Types
243
+
244
+ <a id="type-InputDesc"></a>
245
+
246
+ ### `InputDesc` (desc struct)
247
+
248
+ This peer's player's input: og.PlayerInput's fields but `player` and `tick`.
249
+
250
+ A desc: every field may be omitted and takes its default; `{}` is valid.
251
+
252
+ | Field | Type | Default | Range | Unit | Notes | Doc |
253
+ |---|---|---|---|---|---|---|
254
+ | `buttons` | `number` | `0` | — | — | — | The buttons held, one bit each. |
255
+ | `x` | `number` | `0` | — | — | — | The move axis, -1 to 1. |
256
+ | `y` | `number` | `0` | — | — | — | The move axis, -1 to 1. |
257
+ | `aimX` | `number` | `0` | — | — | — | A second axis. |
258
+ | `aimY` | `number` | `0` | — | — | — | A second axis. |
259
+
260
+ ```ogt
261
+ struct InputDesc {
262
+ doc "This peer's player's input: og.PlayerInput's fields but `player` and `tick`."
263
+ desc true
264
+ field buttons u32 "The buttons held, one bit each."
265
+ field x f32 "The move axis, -1 to 1."
266
+ field y f32 "The move axis, -1 to 1."
267
+ field aimX f32 "A second axis."
268
+ field aimY f32 "A second axis."
269
+ }
270
+ ```
271
+
272
+ <sub>`api.ogt` line 13827</sub>
273
+
274
+ <a id="type-LockstepSeat"></a>
275
+
276
+ ### `LockstepSeat` (struct)
277
+
278
+ One peer's hold on a seat.
279
+
280
+ | Field | Type | Default | Range | Unit | Notes | Doc |
281
+ |---|---|---|---|---|---|---|
282
+ | `seat` | `number` | `0` | — | — | — | The seat. |
283
+ | `peer` | `number` | `0` | — | — | — | The peer that holds (or held) it. |
284
+ | `since` | `number` | `0` | — | `ticks` | — | The first tick of its input. |
285
+ | `until` | `number \| null` | `null` | — | `ticks` | — | The last tick of its input, once it left. |
286
+
287
+ ```ogt
288
+ struct LockstepSeat {
289
+ doc "One peer's hold on a seat."
290
+ field seat u32 "The seat."
291
+ field peer u32 "The peer that holds (or held) it."
292
+ field since f64 "The first tick of its input." {
293
+ unit ticks
294
+ }
295
+ field until Option.f64 "The last tick of its input, once it left." {
296
+ unit ticks
297
+ }
298
+ }
299
+ ```
300
+
301
+ <sub>`api.ogt` line 13837</sub>
302
+
303
+ <a id="type-LockstepStatus"></a>
304
+
305
+ ### `LockstepStatus` (struct)
306
+
307
+ Lockstep on this peer, as the probe and a HUD read it.
308
+
309
+ | Field | Type | Default | Range | Unit | Notes | Doc |
310
+ |---|---|---|---|---|---|---|
311
+ | `running` | `boolean` | `false` | — | — | — | Whether lockstep runs. |
312
+ | `peer` | `number \| null` | `null` | — | — | — | This peer's number; null in no room. |
313
+ | `peers` | `readonly number[]` | `[]` | — | — | — | The peers present, by number. |
314
+ | `startTick` | `number \| null` | `null` | — | `ticks` | — | The tick lockstep started (or this peer joined it) at. |
315
+ | `players` | `number \| null` | `null` | — | — | — | The seats, while running. |
316
+ | `seats` | `readonly LockstepSeat[]` | `[]` | — | — | — | Every seat's holds, in order. |
317
+ | `spectators` | `readonly number[]` | `[]` | — | — | — | The running peers without a seat. |
318
+ | `waitingFor` | `readonly number[]` | `[]` | — | — | — | The seats whose input for the next tick has not arrived. |
319
+ | `waits` | `number` | `0` | — | — | — | Tick boundaries this peer waited at for an input. |
320
+ | `desync` | `number \| null` | `null` | — | — | — | The first divergent tick, once og.Desync was sent. |
321
+
322
+ ```ogt
323
+ struct LockstepStatus {
324
+ doc "Lockstep on this peer, as the probe and a HUD read it."
325
+ field running bool "Whether lockstep runs."
326
+ field peer Option.u32 "This peer's number; null in no room."
327
+ field peers List.u32 "The peers present, by number."
328
+ field startTick Option.f64 "The tick lockstep started (or this peer joined it) at." {
329
+ unit ticks
330
+ }
331
+ field players Option.u32 "The seats, while running."
332
+ field seats List.LockstepSeat "Every seat's holds, in order."
333
+ field spectators List.u32 "The running peers without a seat."
334
+ field waitingFor List.u32 "The seats whose input for the next tick has not arrived."
335
+ field waits f64 "Tick boundaries this peer waited at for an input."
336
+ field desync Option.u32 "The first divergent tick, once og.Desync was sent."
337
+ }
338
+ ```
339
+
340
+ <sub>`api.ogt` line 13849</sub>