@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,127 @@
|
|
|
1
|
+
// Arcade handling and mission rules. Collision, hierarchy and camera tracking are engine services.
|
|
2
|
+
const game = () => molen.get('game', 'courierGame');
|
|
3
|
+
const update = (data: Partial<MolenCourierGameData>) => molen.patch('game', 'courierGame', data);
|
|
4
|
+
molen.patchState({
|
|
5
|
+
dir: molen.state.dir ?? [0, 0],
|
|
6
|
+
brake: molen.state.brake ?? false,
|
|
7
|
+
heading: molen.state.heading ?? 0,
|
|
8
|
+
started: molen.state.started ?? molen.tick,
|
|
9
|
+
hitAt: molen.state.hitAt ?? -60,
|
|
10
|
+
});
|
|
11
|
+
function reset() {
|
|
12
|
+
molen.setState({ dir: [0, 0], brake: false, heading: 0, started: molen.tick, hitAt: -60 });
|
|
13
|
+
molen.patch('player', 'transform', { pos: [0, 0.55, 12], rot: [0, 0, 0, 1], teleport: true });
|
|
14
|
+
molen.patch('player', 'kinematicBody', { vel: [0, 0, 0] });
|
|
15
|
+
update({
|
|
16
|
+
status: 'playing',
|
|
17
|
+
health: 100,
|
|
18
|
+
delivered: 0,
|
|
19
|
+
seconds: config.duration,
|
|
20
|
+
speed: 0,
|
|
21
|
+
message: 'Deliver the five beacons before time runs out.',
|
|
22
|
+
});
|
|
23
|
+
placeBeacon(0);
|
|
24
|
+
for (const [id, car] of molen.query('trafficCar')) {
|
|
25
|
+
molen.patch(id, 'transform', { pos: [car.lane, 0.55, car.start], teleport: true });
|
|
26
|
+
molen.patch(id, 'kinematicBody', { vel: [0, 0, car.speed] });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function placeBeacon(index: number) {
|
|
30
|
+
const point = config.route[index];
|
|
31
|
+
if (!point) {
|
|
32
|
+
molen.patch('beacon', 'renderable', { visible: false });
|
|
33
|
+
molen.patch('beacon-pillar', 'renderable', { visible: false });
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
for (const id of ['beacon', 'beacon-pillar']) {
|
|
37
|
+
molen.patch(id, 'renderable', { visible: true });
|
|
38
|
+
molen.patch(id, 'transform', { pos: [point[0], id === 'beacon' ? 0.12 : 2, point[1]] });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
molen.onCommand('drive', (p) => molen.patchState({ dir: p.dir }));
|
|
42
|
+
molen.onCommand('brake', (p) => molen.patchState({ brake: p.held }));
|
|
43
|
+
molen.onCommand('restart', reset);
|
|
44
|
+
molen.on('collision', (p) => {
|
|
45
|
+
const g = game();
|
|
46
|
+
if (
|
|
47
|
+
!g ||
|
|
48
|
+
(p.a !== 'player' && p.b !== 'player') ||
|
|
49
|
+
g.status !== 'playing' ||
|
|
50
|
+
molen.tick - molen.state.hitAt < 20
|
|
51
|
+
)
|
|
52
|
+
return;
|
|
53
|
+
const speed = g.speed;
|
|
54
|
+
if (speed < 3) return;
|
|
55
|
+
molen.patchState({ hitAt: molen.tick });
|
|
56
|
+
const health = molen.math.max(0, g.health - molen.math.ceil(speed * 1.5));
|
|
57
|
+
update({
|
|
58
|
+
health,
|
|
59
|
+
status: health === 0 ? 'lost' : 'playing',
|
|
60
|
+
message:
|
|
61
|
+
health === 0
|
|
62
|
+
? 'Car totaled. Press R for another run.'
|
|
63
|
+
: 'Collision! Ease off and use the handbrake.',
|
|
64
|
+
});
|
|
65
|
+
molen.emit('crash', { health });
|
|
66
|
+
});
|
|
67
|
+
molen.on('tick', () => {
|
|
68
|
+
const g = game();
|
|
69
|
+
const playerT = molen.get('player', 'transform');
|
|
70
|
+
const body = molen.get('player', 'kinematicBody');
|
|
71
|
+
if (!g || !playerT || !body) return;
|
|
72
|
+
const p = playerT.pos;
|
|
73
|
+
const seconds = molen.math.max(
|
|
74
|
+
0,
|
|
75
|
+
config.duration - molen.math.floor((molen.tick - molen.state.started) * molen.dt),
|
|
76
|
+
);
|
|
77
|
+
if (g.status !== 'playing' || seconds === 0) {
|
|
78
|
+
molen.patch('player', 'kinematicBody', { vel: [0, 0, 0] });
|
|
79
|
+
if (seconds === 0 && g.status === 'playing')
|
|
80
|
+
update({ status: 'lost', seconds: 0, message: 'Time is up. Press R to retry the route.' });
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const v = body.vel;
|
|
84
|
+
let heading = molen.state.heading;
|
|
85
|
+
let forward = -v[0] * molen.math.sin(heading) - v[2] * molen.math.cos(heading);
|
|
86
|
+
const throttle = -molen.state.dir[1];
|
|
87
|
+
forward += throttle * config.acceleration * molen.dt;
|
|
88
|
+
const drag = molen.state.brake ? 8 : throttle === 0 ? 1.5 : 0.35;
|
|
89
|
+
forward *= molen.math.max(0, 1 - drag * molen.dt);
|
|
90
|
+
forward = molen.math.clamp(forward, -7, config.maxSpeed);
|
|
91
|
+
heading -= molen.state.dir[0] * config.steering * molen.math.clamp(forward / 7, -1, 1) * molen.dt;
|
|
92
|
+
const grip = molen.state.brake ? 0.35 : 0.55;
|
|
93
|
+
const vx = -molen.math.sin(heading) * forward;
|
|
94
|
+
const vz = -molen.math.cos(heading) * forward;
|
|
95
|
+
molen.patchState({ heading });
|
|
96
|
+
molen.patch('player', 'transform', {
|
|
97
|
+
rot: [0, molen.math.sin(heading / 2), 0, molen.math.cos(heading / 2)],
|
|
98
|
+
teleport: false,
|
|
99
|
+
});
|
|
100
|
+
molen.patch('player', 'kinematicBody', {
|
|
101
|
+
vel: [v[0] + (vx - v[0]) * grip, 0, v[2] + (vz - v[2]) * grip],
|
|
102
|
+
});
|
|
103
|
+
update({ speed: molen.math.hypot(vx, vz), seconds });
|
|
104
|
+
const point = config.route[g.delivered];
|
|
105
|
+
if (point && molen.math.hypot(p[0] - point[0], p[2] - point[1]) < 3) {
|
|
106
|
+
const delivered = g.delivered + 1;
|
|
107
|
+
update({
|
|
108
|
+
delivered,
|
|
109
|
+
status: delivered === g.total ? 'won' : 'playing',
|
|
110
|
+
message:
|
|
111
|
+
delivered === g.total
|
|
112
|
+
? 'Route complete. Nice driving! Press R to go again.'
|
|
113
|
+
: 'Delivery complete. Follow the next mint beacon.',
|
|
114
|
+
});
|
|
115
|
+
placeBeacon(delivered);
|
|
116
|
+
molen.emit('delivery', { delivered });
|
|
117
|
+
}
|
|
118
|
+
for (const [id, t, car] of molen.query('transform', 'trafficCar')) {
|
|
119
|
+
if (t.pos[2] > car.to || t.pos[2] < car.from)
|
|
120
|
+
molen.patch(id, 'transform', {
|
|
121
|
+
pos: [car.lane, 0.55, car.speed > 0 ? car.from : car.to],
|
|
122
|
+
teleport: true,
|
|
123
|
+
});
|
|
124
|
+
else molen.patch(id, 'transform', { teleport: false });
|
|
125
|
+
molen.patch(id, 'kinematicBody', { vel: [0, 0, car.speed] });
|
|
126
|
+
}
|
|
127
|
+
});
|