@bendyline/molen-tooling 0.0.1 → 0.0.2
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/README.md +22 -4
- package/dist/cli.mjs +26 -4
- package/dist/docs-src/guide/3d-art-guidelines.md +2 -2
- package/dist/docs-src/guide/3d-model-assets.md +15 -11
- package/dist/docs-src/guide/aircraft.md +9 -10
- package/dist/docs-src/guide/browser-mount.md +14 -0
- package/dist/docs-src/guide/building-interiors.md +2 -1
- package/dist/docs-src/guide/determinism.md +16 -11
- package/dist/docs-src/guide/entities.md +16 -5
- package/dist/docs-src/guide/examples.md +38 -23
- package/dist/docs-src/guide/experience-playback.md +2 -3
- package/dist/docs-src/guide/game-samples.md +30 -18
- package/dist/docs-src/guide/project.md +22 -2
- package/dist/docs-src/guide/quickstart.md +37 -28
- package/dist/docs-src/guide/recognizable-places.md +21 -15
- package/dist/docs-src/guide/rendering-backends.md +5 -4
- package/dist/docs-src/guide/scripting.md +4 -2
- package/dist/docs-src/guide/sky.md +10 -9
- package/dist/docs-src/guide/structure-library.md +18 -8
- package/dist/docs-src/guide/terrain.md +6 -4
- package/dist/docs-src/guide/vehicles.md +9 -5
- package/dist/docs-src/guide/worldgen.md +31 -21
- package/dist/docs-src/llms.txt +26 -15
- package/dist/docs-src/schemas/README.md +1 -1
- package/dist/index.d.mts +26 -2
- package/dist/index.mjs +2 -2
- package/dist/{mcp-BFnCWrg0.mjs → mcp-AOfIp89b.mjs} +12 -2
- package/dist/{ops-BGxhSP6w.mjs → ops-C4BvDgP-.mjs} +267 -33
- package/dist/templates/city-courier/README.md +53 -0
- package/dist/templates/city-courier/checks.json +20 -0
- package/dist/templates/city-courier/commands.json +32 -0
- package/dist/templates/city-courier/delivery-run.replay.json +214 -0
- package/dist/templates/city-courier/gen/molen-types.ts +878 -0
- package/dist/templates/city-courier/index.html +2 -0
- package/dist/templates/city-courier/package.json +25 -0
- package/dist/templates/city-courier/project.json +8 -0
- package/dist/templates/city-courier/scene.json +3395 -0
- package/dist/templates/city-courier/scripts/game.ts +127 -0
- package/dist/templates/city-courier/scripts/molen-scripts.d.ts +1125 -0
- package/dist/templates/city-courier/scripts/tsconfig.json +16 -0
- package/dist/templates/city-courier/src/game-shell.css +309 -0
- package/dist/templates/city-courier/src/main.ts +81 -0
- package/dist/templates/city-courier/src/scene.ts +17 -0
- package/dist/templates/city-courier/src/vite-env.d.ts +1 -0
- package/dist/templates/city-courier/src/worker.ts +5 -0
- package/dist/templates/city-courier/test/headless.test.ts +95 -0
- package/dist/templates/city-courier/test/playthrough.test.js +52 -0
- package/dist/templates/city-courier/test/replay.test.ts +22 -0
- package/dist/templates/city-courier/tsconfig.json +17 -0
- package/dist/templates/city-courier/vite.config.ts +19 -0
- package/dist/templates/cubes/README.md +51 -0
- package/dist/templates/cubes/index.html +16 -0
- package/dist/templates/cubes/package.json +24 -0
- package/dist/templates/cubes/scene.json +15 -0
- package/dist/templates/cubes/src/cubes.ts +100 -0
- package/dist/templates/cubes/src/main.ts +21 -0
- package/dist/templates/cubes/src/worker.ts +15 -0
- package/dist/templates/cubes/test/headless.test.ts +98 -0
- package/dist/templates/cubes/tsconfig.json +17 -0
- package/dist/templates/cubes/vite.config.ts +17 -0
- package/dist/templates/data-viz/README.md +47 -0
- package/dist/templates/data-viz/camera-track.json +12 -0
- package/dist/templates/data-viz/data.json +9 -0
- package/dist/templates/data-viz/index.html +16 -0
- package/dist/templates/data-viz/package.json +25 -0
- package/dist/templates/data-viz/scene.json +7 -0
- package/dist/templates/data-viz/src/main.ts +39 -0
- package/dist/templates/data-viz/src/viz.ts +91 -0
- package/dist/templates/data-viz/src/worker.ts +12 -0
- package/dist/templates/data-viz/test/headless.test.ts +75 -0
- package/dist/templates/data-viz/tsconfig.json +17 -0
- package/dist/templates/data-viz/vite.config.ts +16 -0
- package/dist/templates/figures-gallery/README.md +46 -0
- package/dist/templates/figures-gallery/index.html +16 -0
- package/dist/templates/figures-gallery/package.json +25 -0
- package/dist/templates/figures-gallery/scene.json +276 -0
- package/dist/templates/figures-gallery/src/main.ts +44 -0
- package/dist/templates/figures-gallery/src/worker.ts +17 -0
- package/dist/templates/figures-gallery/test/headless.test.ts +90 -0
- package/dist/templates/figures-gallery/tsconfig.json +17 -0
- package/dist/templates/figures-gallery/vite.config.ts +17 -0
- package/dist/templates/index.json +188 -0
- package/dist/templates/skybound/README.md +53 -0
- package/dist/templates/skybound/checks.json +24 -0
- package/dist/templates/skybound/commands.json +32 -0
- package/dist/templates/skybound/first-leap.replay.json +224 -0
- package/dist/templates/skybound/gen/molen-types.ts +878 -0
- package/dist/templates/skybound/index.html +2 -0
- package/dist/templates/skybound/package.json +25 -0
- package/dist/templates/skybound/project.json +8 -0
- package/dist/templates/skybound/scene.json +1737 -0
- package/dist/templates/skybound/scripts/game.ts +119 -0
- package/dist/templates/skybound/scripts/molen-scripts.d.ts +1125 -0
- package/dist/templates/skybound/scripts/tsconfig.json +16 -0
- package/dist/templates/skybound/src/game-shell.css +309 -0
- package/dist/templates/skybound/src/main.ts +60 -0
- package/dist/templates/skybound/src/scene.ts +17 -0
- package/dist/templates/skybound/src/vite-env.d.ts +1 -0
- package/dist/templates/skybound/src/worker.ts +5 -0
- package/dist/templates/skybound/test/headless.test.ts +124 -0
- package/dist/templates/skybound/test/playthrough.test.js +38 -0
- package/dist/templates/skybound/test/replay.test.ts +22 -0
- package/dist/templates/skybound/tsconfig.json +17 -0
- package/dist/templates/skybound/vite.config.ts +19 -0
- package/dist/templates/terrain-flyover/README.md +46 -0
- package/dist/templates/terrain-flyover/index.html +16 -0
- package/dist/templates/terrain-flyover/package.json +26 -0
- package/dist/templates/terrain-flyover/src/flyover.ts +23 -0
- package/dist/templates/terrain-flyover/src/main.ts +93 -0
- package/dist/templates/terrain-flyover/terrain.json +15 -0
- package/dist/templates/terrain-flyover/test/headless.test.ts +72 -0
- package/dist/templates/terrain-flyover/tsconfig.json +17 -0
- package/dist/templates/terrain-flyover/vite.config.ts +15 -0
- package/dist/templates/top-down-arena/README.md +52 -0
- package/dist/templates/top-down-arena/arena-skirmish.replay.json +204 -0
- package/dist/templates/top-down-arena/index.html +16 -0
- package/dist/templates/top-down-arena/package.json +25 -0
- package/dist/templates/top-down-arena/project.json +10 -0
- package/dist/templates/top-down-arena/scene.json +162 -0
- package/dist/templates/top-down-arena/scripts/chase.ts +17 -0
- package/dist/templates/top-down-arena/scripts/combat.ts +12 -0
- package/dist/templates/top-down-arena/scripts/control.ts +8 -0
- package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +1095 -0
- package/dist/templates/top-down-arena/scripts/spawner.ts +11 -0
- package/dist/templates/top-down-arena/scripts/tsconfig.json +16 -0
- package/dist/templates/top-down-arena/src/arena.ts +8 -0
- package/dist/templates/top-down-arena/src/gen/molen-types.ts +882 -0
- package/dist/templates/top-down-arena/src/main.ts +31 -0
- package/dist/templates/top-down-arena/src/scene.ts +24 -0
- package/dist/templates/top-down-arena/src/vite-env.d.ts +1 -0
- package/dist/templates/top-down-arena/src/worker.ts +7 -0
- package/dist/templates/top-down-arena/test/headless.test.ts +87 -0
- package/dist/templates/top-down-arena/test/replay.test.ts +22 -0
- package/dist/templates/top-down-arena/tsconfig.json +17 -0
- package/dist/templates/top-down-arena/types/arena.types.json +54 -0
- package/dist/templates/top-down-arena/vite.config.ts +21 -0
- package/package.json +14 -14
|
@@ -0,0 +1,119 @@
|
|
|
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')
|
|
14
|
+
molen.patch('player', 'platformIntent', {
|
|
15
|
+
...(p.held ? { jump: true } : {}),
|
|
16
|
+
jumpHeld: p.held,
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
molen.onCommand('restart', () => {
|
|
20
|
+
placePlayer(config.spawn);
|
|
21
|
+
update({
|
|
22
|
+
status: 'playing',
|
|
23
|
+
lives: 3,
|
|
24
|
+
coins: 0,
|
|
25
|
+
checkpoint: 0,
|
|
26
|
+
message: 'Follow the floating seeds to the lighthouse.',
|
|
27
|
+
});
|
|
28
|
+
molen.patchState({ invincibleUntil: molen.tick + 30 });
|
|
29
|
+
for (const [id] of molen.query('seedPickup')) {
|
|
30
|
+
molen.patch(id, 'seedPickup', { collected: false });
|
|
31
|
+
molen.patch(id, 'renderable', { visible: true });
|
|
32
|
+
}
|
|
33
|
+
for (const [id, patrol] of molen.query('patrol')) {
|
|
34
|
+
molen.patch(id, 'patrol', { alive: true, direction: 1 });
|
|
35
|
+
molen.patch(id, 'renderable', { visible: true });
|
|
36
|
+
molen.patch(id, 'transform', { pos: [patrol.left, 1, 0], teleport: true });
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
function hurt() {
|
|
40
|
+
const g = game();
|
|
41
|
+
if (g === undefined || molen.tick < (molen.state.invincibleUntil ?? 0)) return;
|
|
42
|
+
const lives = g.lives - 1;
|
|
43
|
+
update({
|
|
44
|
+
lives,
|
|
45
|
+
status: lives === 0 ? 'lost' : 'playing',
|
|
46
|
+
message:
|
|
47
|
+
lives === 0
|
|
48
|
+
? 'Out of lives. Press R for a fresh adventure.'
|
|
49
|
+
: 'Back on your feet. Try a longer jump.',
|
|
50
|
+
});
|
|
51
|
+
placePlayer(g.checkpoint ? config.checkpoint : config.spawn);
|
|
52
|
+
molen.patchState({ invincibleUntil: molen.tick + 30 });
|
|
53
|
+
molen.emit('respawn', { lives });
|
|
54
|
+
}
|
|
55
|
+
molen.on('tick', () => {
|
|
56
|
+
const g = game();
|
|
57
|
+
const playerT = molen.get('player', 'transform');
|
|
58
|
+
if (g === undefined || playerT === undefined) return;
|
|
59
|
+
const p = playerT.pos;
|
|
60
|
+
molen.patch('camera-target', 'transform', { pos: [molen.math.clamp(p[0] + 4, 4, 73), 0, 0] });
|
|
61
|
+
if (g.status !== 'playing') {
|
|
62
|
+
molen.patch('player', 'platformIntent', { move: 0, jump: false });
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
molen.patch('player', 'transform', { teleport: false });
|
|
66
|
+
if (p[1] < -6) {
|
|
67
|
+
hurt();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
for (const [id, t, seed] of molen.query('transform', 'seedPickup')) {
|
|
71
|
+
if (!seed.collected && molen.math.hypot(p[0] - t.pos[0], p[1] - t.pos[1]) < 0.95) {
|
|
72
|
+
molen.patch(id, 'seedPickup', { collected: true });
|
|
73
|
+
molen.patch(id, 'renderable', { visible: false });
|
|
74
|
+
update({ coins: g.coins + 1 });
|
|
75
|
+
molen.emit('seed-collected', { entity: id });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (!g.checkpoint && p[0] >= 37 && p[1] > 0.6) {
|
|
79
|
+
update({ checkpoint: 1, message: 'Checkpoint reached. The lighthouse is just ahead.' });
|
|
80
|
+
molen.emit('checkpoint', {});
|
|
81
|
+
}
|
|
82
|
+
for (const [, t, tag] of molen.query('transform', 'tag')) {
|
|
83
|
+
if (
|
|
84
|
+
tag.name === 'hazard' &&
|
|
85
|
+
molen.math.abs(p[0] - t.pos[0]) < 0.85 &&
|
|
86
|
+
molen.math.abs(p[1] - t.pos[1]) < 0.8
|
|
87
|
+
) {
|
|
88
|
+
hurt();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
for (const [id, t, patrol] of molen.query('transform', 'patrol')) {
|
|
93
|
+
if (!patrol.alive) continue;
|
|
94
|
+
const direction =
|
|
95
|
+
t.pos[0] >= patrol.right ? -1 : t.pos[0] <= patrol.left ? 1 : patrol.direction;
|
|
96
|
+
molen.patch(id, 'patrol', { direction });
|
|
97
|
+
molen.patch(id, 'transform', {
|
|
98
|
+
pos: [t.pos[0] + direction * 1.7 * molen.dt, t.pos[1], 0],
|
|
99
|
+
teleport: false,
|
|
100
|
+
});
|
|
101
|
+
if (molen.math.abs(p[0] - t.pos[0]) < 0.72 && molen.math.abs(p[1] - t.pos[1]) < 1.1) {
|
|
102
|
+
const body = molen.get('player', 'platformBody');
|
|
103
|
+
if (body === undefined) return;
|
|
104
|
+
if ((body.vel?.[1] ?? 0) < 0 && p[1] - 0.65 > t.pos[1] + 0.05) {
|
|
105
|
+
molen.patch(id, 'patrol', { alive: false });
|
|
106
|
+
molen.patch(id, 'renderable', { visible: false });
|
|
107
|
+
molen.patch('player', 'platformBody', { vel: [body.vel?.[0] ?? 0, 10], grounded: false });
|
|
108
|
+
molen.emit('stomp', { entity: id });
|
|
109
|
+
} else {
|
|
110
|
+
hurt();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (p[0] >= config.finish && p[1] > 0.6) {
|
|
116
|
+
update({ status: 'won', message: 'The lighthouse is lit! Press R to collect every seed.' });
|
|
117
|
+
molen.emit('victory', {});
|
|
118
|
+
}
|
|
119
|
+
});
|