@bendyline/molen-tooling 0.0.1 → 0.0.3

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 (158) hide show
  1. package/README.md +22 -4
  2. package/dist/capture/harness.js +216 -216
  3. package/dist/capture/worldgen-preview.js +288 -288
  4. package/dist/cli.mjs +134 -12
  5. package/dist/docs-src/guide/3d-art-guidelines.md +2 -2
  6. package/dist/docs-src/guide/3d-model-assets.md +49 -13
  7. package/dist/docs-src/guide/adaptive-performance.md +4 -0
  8. package/dist/docs-src/guide/agent-loop.md +6 -6
  9. package/dist/docs-src/guide/aircraft.md +25 -17
  10. package/dist/docs-src/guide/audio.md +247 -0
  11. package/dist/docs-src/guide/browser-mount.md +17 -1
  12. package/dist/docs-src/guide/building-interiors.md +7 -5
  13. package/dist/docs-src/guide/determinism.md +27 -22
  14. package/dist/docs-src/guide/earth-view.md +444 -0
  15. package/dist/docs-src/guide/entities.md +17 -6
  16. package/dist/docs-src/guide/examples.md +39 -23
  17. package/dist/docs-src/guide/experience-playback.md +2 -3
  18. package/dist/docs-src/guide/game-samples.md +50 -21
  19. package/dist/docs-src/guide/graphics-performance.md +40 -8
  20. package/dist/docs-src/guide/input.md +9 -0
  21. package/dist/docs-src/guide/markers.md +52 -0
  22. package/dist/docs-src/guide/materials.md +10 -3
  23. package/dist/docs-src/guide/navigation.md +144 -0
  24. package/dist/docs-src/guide/project.md +23 -3
  25. package/dist/docs-src/guide/quickstart.md +39 -30
  26. package/dist/docs-src/guide/recognizable-places.md +24 -17
  27. package/dist/docs-src/guide/rendering-backends.md +5 -4
  28. package/dist/docs-src/guide/scripting.md +8 -4
  29. package/dist/docs-src/guide/sky.md +26 -9
  30. package/dist/docs-src/guide/source-bundles.md +0 -1
  31. package/dist/docs-src/guide/structure-library.md +20 -10
  32. package/dist/docs-src/guide/terrain.md +51 -6
  33. package/dist/docs-src/guide/vehicles.md +27 -14
  34. package/dist/docs-src/guide/worldgen.md +34 -24
  35. package/dist/docs-src/llms.txt +35 -18
  36. package/dist/docs-src/schemas/README.md +4 -1
  37. package/dist/docs-src/schemas/archive-set.md +175 -0
  38. package/dist/docs-src/schemas/components.md +1104 -1
  39. package/dist/docs-src/schemas/matgraph.md +6 -0
  40. package/dist/docs-src/schemas/soundbank.md +251 -0
  41. package/dist/docs-src/schemas/structure-placements.md +496 -0
  42. package/dist/docs-src/schemas/terrain-package.md +120 -0
  43. package/dist/index.d.mts +31 -3
  44. package/dist/index.mjs +2 -2
  45. package/dist/{mcp-BFnCWrg0.mjs → mcp-BTVwVKFb.mjs} +78 -4
  46. package/dist/{ops-BGxhSP6w.mjs → ops-BPdHodFR.mjs} +1181 -61
  47. package/dist/templates/city-courier/README.md +66 -0
  48. package/dist/templates/city-courier/checks.json +20 -0
  49. package/dist/templates/city-courier/commands.json +32 -0
  50. package/dist/templates/city-courier/delivery-run.replay.json +214 -0
  51. package/dist/templates/city-courier/gen/molen-types.ts +1016 -0
  52. package/dist/templates/city-courier/index.html +2 -0
  53. package/dist/templates/city-courier/package.json +26 -0
  54. package/dist/templates/city-courier/project.json +8 -0
  55. package/dist/templates/city-courier/scene.json +3474 -0
  56. package/dist/templates/city-courier/scripts/game.ts +131 -0
  57. package/dist/templates/city-courier/scripts/molen-scripts.d.ts +1288 -0
  58. package/dist/templates/city-courier/scripts/tsconfig.json +16 -0
  59. package/dist/templates/city-courier/src/audio.ts +96 -0
  60. package/dist/templates/city-courier/src/game-shell.css +317 -0
  61. package/dist/templates/city-courier/src/main.ts +84 -0
  62. package/dist/templates/city-courier/src/scene.ts +17 -0
  63. package/dist/templates/city-courier/src/vite-env.d.ts +1 -0
  64. package/dist/templates/city-courier/src/worker.ts +5 -0
  65. package/dist/templates/city-courier/test/headless.test.ts +95 -0
  66. package/dist/templates/city-courier/test/playthrough.test.js +52 -0
  67. package/dist/templates/city-courier/test/replay.test.ts +22 -0
  68. package/dist/templates/city-courier/tsconfig.json +17 -0
  69. package/dist/templates/city-courier/vite.config.ts +19 -0
  70. package/dist/templates/cubes/README.md +51 -0
  71. package/dist/templates/cubes/index.html +16 -0
  72. package/dist/templates/cubes/package.json +24 -0
  73. package/dist/templates/cubes/scene.json +15 -0
  74. package/dist/templates/cubes/src/cubes.ts +100 -0
  75. package/dist/templates/cubes/src/main.ts +21 -0
  76. package/dist/templates/cubes/src/worker.ts +15 -0
  77. package/dist/templates/cubes/test/headless.test.ts +98 -0
  78. package/dist/templates/cubes/tsconfig.json +17 -0
  79. package/dist/templates/cubes/vite.config.ts +17 -0
  80. package/dist/templates/data-viz/README.md +47 -0
  81. package/dist/templates/data-viz/camera-track.json +12 -0
  82. package/dist/templates/data-viz/data.json +9 -0
  83. package/dist/templates/data-viz/index.html +16 -0
  84. package/dist/templates/data-viz/package.json +25 -0
  85. package/dist/templates/data-viz/scene.json +7 -0
  86. package/dist/templates/data-viz/src/main.ts +39 -0
  87. package/dist/templates/data-viz/src/viz.ts +91 -0
  88. package/dist/templates/data-viz/src/worker.ts +12 -0
  89. package/dist/templates/data-viz/test/headless.test.ts +75 -0
  90. package/dist/templates/data-viz/tsconfig.json +17 -0
  91. package/dist/templates/data-viz/vite.config.ts +16 -0
  92. package/dist/templates/figures-gallery/README.md +46 -0
  93. package/dist/templates/figures-gallery/index.html +16 -0
  94. package/dist/templates/figures-gallery/package.json +25 -0
  95. package/dist/templates/figures-gallery/scene.json +276 -0
  96. package/dist/templates/figures-gallery/src/main.ts +44 -0
  97. package/dist/templates/figures-gallery/src/worker.ts +17 -0
  98. package/dist/templates/figures-gallery/test/headless.test.ts +90 -0
  99. package/dist/templates/figures-gallery/tsconfig.json +17 -0
  100. package/dist/templates/figures-gallery/vite.config.ts +17 -0
  101. package/dist/templates/index.json +191 -0
  102. package/dist/templates/skybound/README.md +66 -0
  103. package/dist/templates/skybound/checks.json +24 -0
  104. package/dist/templates/skybound/commands.json +32 -0
  105. package/dist/templates/skybound/first-leap.replay.json +224 -0
  106. package/dist/templates/skybound/gen/molen-types.ts +1016 -0
  107. package/dist/templates/skybound/index.html +2 -0
  108. package/dist/templates/skybound/package.json +26 -0
  109. package/dist/templates/skybound/project.json +8 -0
  110. package/dist/templates/skybound/scene.json +1777 -0
  111. package/dist/templates/skybound/scripts/game.ts +122 -0
  112. package/dist/templates/skybound/scripts/molen-scripts.d.ts +1288 -0
  113. package/dist/templates/skybound/scripts/tsconfig.json +16 -0
  114. package/dist/templates/skybound/src/audio.ts +96 -0
  115. package/dist/templates/skybound/src/game-shell.css +317 -0
  116. package/dist/templates/skybound/src/main.ts +63 -0
  117. package/dist/templates/skybound/src/scene.ts +17 -0
  118. package/dist/templates/skybound/src/vite-env.d.ts +1 -0
  119. package/dist/templates/skybound/src/worker.ts +5 -0
  120. package/dist/templates/skybound/test/headless.test.ts +124 -0
  121. package/dist/templates/skybound/test/playthrough.test.js +38 -0
  122. package/dist/templates/skybound/test/replay.test.ts +22 -0
  123. package/dist/templates/skybound/tsconfig.json +17 -0
  124. package/dist/templates/skybound/vite.config.ts +19 -0
  125. package/dist/templates/terrain-flyover/README.md +46 -0
  126. package/dist/templates/terrain-flyover/index.html +16 -0
  127. package/dist/templates/terrain-flyover/package.json +26 -0
  128. package/dist/templates/terrain-flyover/src/flyover.ts +23 -0
  129. package/dist/templates/terrain-flyover/src/main.ts +93 -0
  130. package/dist/templates/terrain-flyover/terrain.json +15 -0
  131. package/dist/templates/terrain-flyover/test/headless.test.ts +72 -0
  132. package/dist/templates/terrain-flyover/tsconfig.json +17 -0
  133. package/dist/templates/terrain-flyover/vite.config.ts +15 -0
  134. package/dist/templates/top-down-arena/README.md +65 -0
  135. package/dist/templates/top-down-arena/arena-skirmish.replay.json +204 -0
  136. package/dist/templates/top-down-arena/index.html +16 -0
  137. package/dist/templates/top-down-arena/package.json +26 -0
  138. package/dist/templates/top-down-arena/project.json +10 -0
  139. package/dist/templates/top-down-arena/scene.json +182 -0
  140. package/dist/templates/top-down-arena/scripts/chase.ts +17 -0
  141. package/dist/templates/top-down-arena/scripts/combat.ts +13 -0
  142. package/dist/templates/top-down-arena/scripts/control.ts +8 -0
  143. package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +1258 -0
  144. package/dist/templates/top-down-arena/scripts/spawner.ts +11 -0
  145. package/dist/templates/top-down-arena/scripts/tsconfig.json +16 -0
  146. package/dist/templates/top-down-arena/src/arena.ts +8 -0
  147. package/dist/templates/top-down-arena/src/audio.ts +96 -0
  148. package/dist/templates/top-down-arena/src/gen/molen-types.ts +1020 -0
  149. package/dist/templates/top-down-arena/src/main.ts +34 -0
  150. package/dist/templates/top-down-arena/src/scene.ts +24 -0
  151. package/dist/templates/top-down-arena/src/vite-env.d.ts +1 -0
  152. package/dist/templates/top-down-arena/src/worker.ts +7 -0
  153. package/dist/templates/top-down-arena/test/headless.test.ts +87 -0
  154. package/dist/templates/top-down-arena/test/replay.test.ts +22 -0
  155. package/dist/templates/top-down-arena/tsconfig.json +17 -0
  156. package/dist/templates/top-down-arena/types/arena.types.json +54 -0
  157. package/dist/templates/top-down-arena/vite.config.ts +21 -0
  158. package/package.json +14 -14
@@ -0,0 +1,122 @@
1
+ // Collect, stomp, checkpoint, finish. The platformer service owns movement and all solid collision.
2
+ const game = () => molen.get('game', 'skyGame');
3
+ const update = (value: Partial<MolenSkyGameData>) => molen.patch('game', 'skyGame', value);
4
+ function placePlayer(pos: [number, number, number]) {
5
+ molen.patch('player', 'transform', { pos, teleport: true });
6
+ molen.patch('player', 'platformBody', { vel: [0, 0], grounded: false, grace: 0, buffered: 0 });
7
+ molen.patch('player', 'platformIntent', { move: 0, jump: false, jumpHeld: false });
8
+ }
9
+ molen.onCommand('move', (p) => {
10
+ if (game()?.status === 'playing') molen.patch('player', 'platformIntent', { move: p.dir[0] });
11
+ });
12
+ molen.onCommand('jump', (p) => {
13
+ if (game()?.status !== 'playing') return;
14
+ molen.patch('player', 'platformIntent', {
15
+ ...(p.held ? { jump: true } : {}),
16
+ jumpHeld: p.held,
17
+ });
18
+ // Only a jump that can happen (on the ground, or within coyote time) makes a sound.
19
+ const body = molen.get('player', 'platformBody');
20
+ if (p.held && (body?.grounded || (body?.grace ?? 0) > 0)) molen.audio.play('game.jump');
21
+ });
22
+ molen.onCommand('restart', () => {
23
+ placePlayer(config.spawn);
24
+ update({
25
+ status: 'playing',
26
+ lives: 3,
27
+ coins: 0,
28
+ checkpoint: 0,
29
+ message: 'Follow the floating seeds to the lighthouse.',
30
+ });
31
+ molen.patchState({ invincibleUntil: molen.tick + 30 });
32
+ for (const [id] of molen.query('seedPickup')) {
33
+ molen.patch(id, 'seedPickup', { collected: false });
34
+ molen.patch(id, 'renderable', { visible: true });
35
+ }
36
+ for (const [id, patrol] of molen.query('patrol')) {
37
+ molen.patch(id, 'patrol', { alive: true, direction: 1 });
38
+ molen.patch(id, 'renderable', { visible: true });
39
+ molen.patch(id, 'transform', { pos: [patrol.left, 1, 0], teleport: true });
40
+ }
41
+ });
42
+ function hurt() {
43
+ const g = game();
44
+ if (g === undefined || molen.tick < (molen.state.invincibleUntil ?? 0)) return;
45
+ const lives = g.lives - 1;
46
+ update({
47
+ lives,
48
+ status: lives === 0 ? 'lost' : 'playing',
49
+ message:
50
+ lives === 0
51
+ ? 'Out of lives. Press R for a fresh adventure.'
52
+ : 'Back on your feet. Try a longer jump.',
53
+ });
54
+ placePlayer(g.checkpoint ? config.checkpoint : config.spawn);
55
+ molen.patchState({ invincibleUntil: molen.tick + 30 });
56
+ molen.emit('respawn', { lives });
57
+ }
58
+ molen.on('tick', () => {
59
+ const g = game();
60
+ const playerT = molen.get('player', 'transform');
61
+ if (g === undefined || playerT === undefined) return;
62
+ const p = playerT.pos;
63
+ molen.patch('camera-target', 'transform', { pos: [molen.math.clamp(p[0] + 4, 4, 73), 0, 0] });
64
+ if (g.status !== 'playing') {
65
+ molen.patch('player', 'platformIntent', { move: 0, jump: false });
66
+ return;
67
+ }
68
+ molen.patch('player', 'transform', { teleport: false });
69
+ if (p[1] < -6) {
70
+ hurt();
71
+ return;
72
+ }
73
+ for (const [id, t, seed] of molen.query('transform', 'seedPickup')) {
74
+ if (!seed.collected && molen.math.hypot(p[0] - t.pos[0], p[1] - t.pos[1]) < 0.95) {
75
+ molen.patch(id, 'seedPickup', { collected: true });
76
+ molen.patch(id, 'renderable', { visible: false });
77
+ update({ coins: g.coins + 1 });
78
+ molen.emit('seed-collected', { entity: id });
79
+ }
80
+ }
81
+ if (!g.checkpoint && p[0] >= 37 && p[1] > 0.6) {
82
+ update({ checkpoint: 1, message: 'Checkpoint reached. The lighthouse is just ahead.' });
83
+ molen.emit('checkpoint', {});
84
+ }
85
+ for (const [, t, tag] of molen.query('transform', 'tag')) {
86
+ if (
87
+ tag.name === 'hazard' &&
88
+ molen.math.abs(p[0] - t.pos[0]) < 0.85 &&
89
+ molen.math.abs(p[1] - t.pos[1]) < 0.8
90
+ ) {
91
+ hurt();
92
+ return;
93
+ }
94
+ }
95
+ for (const [id, t, patrol] of molen.query('transform', 'patrol')) {
96
+ if (!patrol.alive) continue;
97
+ const direction =
98
+ t.pos[0] >= patrol.right ? -1 : t.pos[0] <= patrol.left ? 1 : patrol.direction;
99
+ molen.patch(id, 'patrol', { direction });
100
+ molen.patch(id, 'transform', {
101
+ pos: [t.pos[0] + direction * 1.7 * molen.dt, t.pos[1], 0],
102
+ teleport: false,
103
+ });
104
+ if (molen.math.abs(p[0] - t.pos[0]) < 0.72 && molen.math.abs(p[1] - t.pos[1]) < 1.1) {
105
+ const body = molen.get('player', 'platformBody');
106
+ if (body === undefined) return;
107
+ if ((body.vel?.[1] ?? 0) < 0 && p[1] - 0.65 > t.pos[1] + 0.05) {
108
+ molen.patch(id, 'patrol', { alive: false });
109
+ molen.patch(id, 'renderable', { visible: false });
110
+ molen.patch('player', 'platformBody', { vel: [body.vel?.[0] ?? 0, 10], grounded: false });
111
+ molen.emit('stomp', { entity: id });
112
+ } else {
113
+ hurt();
114
+ return;
115
+ }
116
+ }
117
+ }
118
+ if (p[0] >= config.finish && p[1] > 0.6) {
119
+ update({ status: 'won', message: 'The lighthouse is lit! Press R to collect every seed.' });
120
+ molen.emit('victory', {});
121
+ }
122
+ });